Skip to content

Commit

Permalink
fix: lock inconsistency on player spawned vehicles
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 committed Dec 22, 2023
1 parent 24e8874 commit 8b0f2b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,12 @@ RegisterNetEvent("ND_Vehicles:toggleVehicleLock", function(netId)
end)

-- 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

local state = Entity(entity).state
if state.owner or state.locked ~= nil then return end

Expand Down

0 comments on commit 8b0f2b0

Please sign in to comment.