fix(server/vehicle): entity exists check

This commit is contained in:
Andyyy7666
2023-08-25 03:09:34 +02:00
parent 46fc396924
commit 105ac16560

View File

@@ -340,10 +340,12 @@ else
NDCore.giveVehicleKeys(veh, src, target) NDCore.giveVehicleKeys(veh, src, target)
end, false) end, false)
end end
RegisterNetEvent("entityCreated", function(entity) RegisterNetEvent("entityCreated", function(entity)
if 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 math.random(1, 100) <= Config.randomUnlockedVehicleChance then return end if state.owner or math.random(1, 100) <= Config.randomUnlockedVehicleChance then return end
if state.locked ~= nil then return end if state.locked ~= nil then return end
state.locked = true state.locked = true
end) end)