2026-04-14 17:41:39 +02:00

21 lines
731 B
Lua

function VehiclesKeys.searchForKeys(vehicle)
Entity(vehicle).state:set("hasAlreadySearchedForKeys", true, true)
local timeInMs = config.secondsToSearchForKeys * 1000
Dialogs.startProgressBar(timeInMs, getLocalizedText("searching_for_keys"))
VehiclesKeys.playHotwireAnimation(timeInMs)
Citizen.Wait(timeInMs)
if(not Entity(vehicle).state.areKeysInVehicle and math.random(1, 100) > config.chancesToFindKeys) then
notifyClient(getLocalizedText("no_keys_found"))
return
end
TriggerServerEvent("vehicles_keys:selfGiveCurrentVehicleKeys")
notifyClient(getLocalizedText("keys_found"))
Citizen.Wait(2000) -- So the keys are given properly, don't remove
end