Server side vehicles being frozen at random

Spawning vehicles server side sometimes leads to those vehicles being frozen in place. This can be detected using IsEntityPositionFrozen on both client and server side.
Seems to happen across the board on all server versions, Linux or Windows doesn’t matter. I’ve had reports reaching all the way back to late 2024.

My resource AdvancedParking uses CreateVehicleServerSetter extensively. This resource runs on 1000+ servers and I get occasional reports about this behavior which can only really be fixed by an admin/mod on the server by using noclip while in the vehicle to essentially unfreeze it. Some servers suffer from this on a daily basis with multiple vehicles, others have never encountered this problem. And so far I could not find any sort of connection between the ones that do have it.

Since it is impossible to know why the vehicle was frozen, I cannot just unfreeze it as it might have been frozen on purpose (e.g. one of the many mechanic scripts out there etc).

The sheer randomness leads me to believe that this might be caused by the network sync from the server itself. E.g. some values not propagating properly… or a safety feature freezing the vehicles so that they don’t fall (collision issues?).

In the recent experimental version of my script that has received consistent updates (especially for debugging purposes) introduced a file that overwrites FreezeEntityPosition in (client and server side) Lua resources and allows logging when it happened to which vehicle. Some of my customers have adopted this version and introduced this file in all of their resources that contain that native. And on server side I explicitly introduced a check that checks all vehicles and if any of them has been (un)frozen.
I could not find any connection to this issue. The server side check sometimes catches frozen vehicles without a corresponding debug line from the file mentioned above. These are the ones that are then reported to me by the server owner as normal players simply cannot do anything about this frozen state as you can imagine.

So far the only consistent thing seems to be that it happens when a vehicle just spawned successfully. I will use this to create a workaround and forcefully unfreeze the vehicle shortly after spawning.
However that doesn’t fix the underlying issue and especially any script that explicitly sets a vehicle as frozen upon spawn will be broken through that workaround without further changes.

How AdvancedParking works under the hood / reproduction steps:

  1. Spawn vehicle using CreateVehicleServerSetter in a radius up to 200m around the nearest player.
  2. Setting a state bag on that vehicle containing all necessary data (tuning, extras, etc.).
  3. Setting all previously saved state bags (yes, we made sure that none of them cause the freezing).
  4. Client receives data state bag, applies all changes.
  5. Server waits until all necessary client changes have been detected.
  6. Sets the data state bag to nil so it doesn’t get applied each and every time.

I have never been able to reproduce the issue on my end but I’ve been witness to many times on my customers servers. It has only happened to a load of customers so far and things like player count and how many vehicles have been saved in AdvancedParking does not seem to matter. There are servers with 100+ players and several hundreds of vehicles that don’t encounter it… Some others do have it on a daily basis.
The current most active customer (latest check: Gamebuild 3407; b13943/Win) that I chat with about this issue has around 30 saved vehicles (not a lot compared to most servers) and 3-5 each day have this issue after spawning.

1 Like

This occurs with client side spawning, as we used that then save the locations of the vehicles to have persistant vehicles (due to a number of issues with server side spawning that make it unreliable) and usually happens when a user teleports/changes buckets, usually with housing scripts.

The vehicles that get stuck are usually on inclines/ramps, I think another side effect of this is peds and cars “falling” through the map. Believe it’s a sync issue from our limited testing. Can be somewhat reproduced by teleporting.

The only problem my customers seem to run into consistently is this freezing problem.

Though I agree that teleporting, but especially routing bucket changes can exaggerate this problem.

Inclines and ramps is not something I can say, most screenshots/videos show all kinds of locations and most of them are on flat ground. Usually you can see the wheels very slightly clipping into the ground.
Falling through the map is also something I can confirm is not happening in my cases. (server side catches position updates if no players are present but there are no debug prints)

If you can share some of the screenshots, I’ve noticed it’s either inclines or ramps, or the vehicle is on top of some object. I haven’t done any specific testing, but it’s usually when a vehicle has the possibility for its position to be changed based on environmental factors.

At the airport, completely flat:


Slightly in the ground:

Okay, this one is on a slight incline :stuck_out_tongue:

For more I probably need to scour the archives, these are the ones I could find immediately :joy:

Do not use SetEntityCoords on the vehicle (both client and server side). There is some sort of collision check in there that causes this behavior. I was pulling my hair out because of that. SetEntityCoordsNoOffset works as it should.
Had a lot of reports where vehicles below roofs (e.g. garages, workshops etc) would appear on top of the roofs. And I was able to reproduce those consistently. After switching to the “no offset” native no more problems here.

Near a curb, which the car could have been parked on - I noticed this issue quite a bit when we had a drug spot (they were handled with a teleporter into an IPL) with parking spots nearby, players would park in the parking spot, and for some reason the ones with the the yellow parking barriers/concrete bars would consistently have issues with cars “Stuck” once a player teleproted back into the area.

SetEntityCoordsNoOffset works as it should.

Good to know, we’ll try that out and see if it improves overall reliability, quite a bit of scripts just use SetEntityCoords works, hopefully not all escrowed :upside_down_face:

AP is precise and updates vehicle positions even from external movement. So the position you see it in is pretty much also the last saved position. That vehicle sits pretty much right in the middle of that marked parking spot.

I’ll keep an eye out, though I have to wait for reports and not everyone sends screenshots or forgets etc.

What I currently use:

SetEntityCoordsNoOffset(vehicle, x, y, z, false, false, true)

https://docs.fivem.net/natives/?_0x239A3351AC1DA385

This native allows precise placement of entities without the usual adjustments for collision or interaction with the environment that may occur with other teleportation natives.