fix: lock inconsistency on player spawned vehicles

This commit is contained in:
Andyyy7666
2023-12-22 18:25:00 +01:00
parent 24e8874050
commit 8b0f2b010d

View File

@@ -567,8 +567,12 @@ RegisterNetEvent("ND_Vehicles:toggleVehicleLock", function(netId)
end) end)
-- locking of npc vehicles, if the players spawns inside a vehicle it won't be locked. -- locking of npc vehicles, if the players spawns inside a vehicle it won't be locked.
RegisterNetEvent("entityCreated", function(entity) AddEventHandler("entityCreated", function(entity)
local time = os.time()
while not DoesEntityExist(entity) and os.time()-time < 5 do Wait(50) end
if not DoesEntityExist(entity) or GetEntityType(entity) ~= 2 then return end if not DoesEntityExist(entity) or GetEntityType(entity) ~= 2 then return end
local state = Entity(entity).state local state = Entity(entity).state
if state.owner or state.locked ~= nil then return end if state.owner or state.locked ~= nil then return end