You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in FiveM that makes it so server spawned vehicles can be deleted. This can happen even when a player is driving it.
Ideal solution
When a vehicle is deleted, it is respawned at the position it was deleted, with the same vehicle properties.
Using the server side entityRemoved event, we can intercept the entity deletion to cache some data about the vehicle, such as the vehicleId, plate, and coords. Then, we can lookup the vehicle in the database to determine whether it is an owned vehicle and respawn it. This could result in stale vehicle properties however, as the database may not have been recently updated.
Therefore, in addition to the above solution, we should also save vehicle properties to the database on an on-demand basis. That is, whenever it changes. Only a client can read the vehicle properties, and would need to send this to the server when it changed. Therefore I propose that when a client is occupying the driver seat of a vehicle, regardless of whether it is the entity owner or not it should do the following:
cache the vehicle properties
every few seconds, check if the vehicle properties have changed
send the diff (if there is one) to the server
The server will then
receive the diff from the client
read the vehicle from the database
overwrite diffed fields
save the vehicle properties back
If this proves to be too much of a performance cost, the server could save to a buffer, and flush the buffer on a less regular cadence, but this should only be done if there proves to be an issue, not before as it adds its own complications, drawbacks, and edge cases.
Exploits in this solution aren't entirely preventable, as the client is the source of truth for the vehicle property data. To prevent exploits to the extent possible, the following can be done:
Only fields changed outside of other events need be accepted by the server. Changing the owner of a vehicle, or its mods for example should result in a separate event on its own rather than be changed through a regular properties detection solution. The vehicles the server could accept would be limited to damage and fuel fields.
if there is a non RPC server native to get the data, the server will use it rather than trust the value sent by the client
anomalous diffs could be detected. i.e. if a vehicle is repaired, we might expect the event to be sent by the script that did the repairing, and so a regular client diff would point to lua injection. This isn't recommended however, as it would assume that all scripts which repair vehicles would be sending property update events to the server.
Alternative solutions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
The problem
There is a bug in FiveM that makes it so server spawned vehicles can be deleted. This can happen even when a player is driving it.
Ideal solution
When a vehicle is deleted, it is respawned at the position it was deleted, with the same vehicle properties.
Using the server side entityRemoved event, we can intercept the entity deletion to cache some data about the vehicle, such as the vehicleId, plate, and coords. Then, we can lookup the vehicle in the database to determine whether it is an owned vehicle and respawn it. This could result in stale vehicle properties however, as the database may not have been recently updated.
Therefore, in addition to the above solution, we should also save vehicle properties to the database on an on-demand basis. That is, whenever it changes. Only a client can read the vehicle properties, and would need to send this to the server when it changed. Therefore I propose that when a client is occupying the driver seat of a vehicle, regardless of whether it is the entity owner or not it should do the following:
The server will then
If this proves to be too much of a performance cost, the server could save to a buffer, and flush the buffer on a less regular cadence, but this should only be done if there proves to be an issue, not before as it adds its own complications, drawbacks, and edge cases.
Exploits in this solution aren't entirely preventable, as the client is the source of truth for the vehicle property data. To prevent exploits to the extent possible, the following can be done:
Alternative solutions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: