1. Environment information
Production client, recommended server artifacts (5562), game build 2189
2. Description
A server-side vehicle is spawned using ‘CREATE_AUTOMOBILE’.
Entity distance culling radius is set to 1500 meters on the created entity through a native.
- Client 1 is near the spawned vehicle and gains vehicle ownership
- Client 1 leaves the area to a location which is ~1200m away from the vehicle.
- Clients 2 comes near the vehicle
- Clients 2 tries to enter the vehicle
3. Expected behaviour
Client 2 is able to enter the vehicle.
4. Actual behaviour
Client 2 gets frozen when trying to enter the vehicle.
5. Reproducing the bug
- Launch two clients (-cl2)
- Place both clients at the same position - command /tp2
- Place client 1 near the vehicle spawn - command /ped
- Spawn the vehicle - command /veh
- Leave the area with client 1 - command /tp2
- Enter the area with client 2 - command /ped
- Try to enter the vehicle with client 2 - you get frozen
CODE - Reproducing - server.lua
local vehicle
local vehicleSpawnPos = vector3(2758.566, 1376.277, 24.519)
local vehicleSpawnPedPos = vector4(2755.7, 1376.0, 24.52, 270.0)
local distance1260Pos = vector3(1512.252, 1519.996, 106.725)
RegisterCommand('ped', function(source)
local playerPed = GetPlayerPed(source)
SetEntityCoords(playerPed, vehicleSpawnPedPos)
end)
RegisterCommand('veh', function()
local CreateAutomobile = GetHashKey('CREATE_AUTOMOBILE')
vehicle = Citizen.InvokeNative(CreateAutomobile, GetHashKey('asbo'), vehicleSpawnPos)
while not DoesEntityExist(vehicle) do
Citizen.Wait(0)
end
SetEntityDistanceCullingRadius(vehicle, 1500.0)
end)
RegisterCommand('tp2', function(source)
SetEntityCoords(GetPlayerPed(source), distance1260Pos)
end)
RegisterCommand('dv', function()
DeleteEntity(vehicle)
end)
Video of reproducing the error using the steps provided above: 2022-07-28 16-15-41
6. Speculating on the causes
Generally, the vehicle driver has ownership of the entity. When client 2 tries to enter the vehicle, he is unable to get the ownership from client 1 and can’t enter the vehicle. As soon as client 1 comes back to the vehicle, client 2 gets unfrozen and enters the vehicle successfully (seen in the video as well). Probably because the culling distance which was set is more than the default OneSync distance.
Backstory
Was trying to achieve persistent vehicles that wouldn’t despawn. Spawned 200 vehicles throughout Los Santos to test this. Vehicles spawned through CREATE_AUTOMOBILE are persistent when the server is empty / you are alone in the server. When multiple clients are moving around, the vehicles started to despawn rapidly.
My second approach was to increase the entity distance culling radius (which caused this bug report) as was suggested in some places. When trying it out, a lot of the players were unable to enter their vehicles, presumably because the ownership of the created vehicle went to someone far away.
This bug has been noticed in the past too, but we have not been able to reproduce it reliably until now. Using SetEntityDistanceCullingRadius makes it reproducible (although not sure if the cause is same).
Anyway, I assume the player should not be frozen trying to get into the vehicle no matter what. Or is this really a side-effect of using this native? Apologies if it is.