diff --git a/bridge/qb/server.lua b/bridge/qb/server.lua index 71039de..bc21036 100644 --- a/bridge/qb/server.lua +++ b/bridge/qb/server.lua @@ -4,8 +4,12 @@ local function giveKeys(source, plate) local vehicles = plate and GetVehiclesFromPlate(plate) or {GetVehiclePedIsIn(GetPlayerPed(source), false)} local success = false for i = 1, #vehicles do - if GiveKeys(source, vehicles[i], true) then - success = true + local vehicle = vehicles[i] + if DoesEntityExist(vehicle) then + if GiveKeys(source, vehicles[i], true) then + success = true + end + Wait(20) end end if success then @@ -20,8 +24,12 @@ local function removeKeys(source, plate) local vehicles = GetVehiclesFromPlate(plate) local success = false for i = 1, #vehicles do - if RemoveKeys(source, vehicles[i], true) then - success = true + local vehicle = vehicles[i] + if DoesEntityExist(vehicle) then + if RemoveKeys(source, vehicle, true) then + success = true + end + Wait(20) end end if success then