So below is a working vehicle repair code i've managed to put together and repairs the damaged vehicle every minute as intended but i just cant seem to reset the timer when the player is wasted. If anyone has an idea, would be much appreciated ?
local repairDelayTime = 60000
local repairTimer = false
function repairVehicle()
local vehicle = getPedOccupiedVehicle(localPlayer)
if isPedDead(localPlayer) and isPedInVehicle(localPlayer) then
return
end
if isTimer(repairTimer) then
local timeleft = math.ceil(getTimerDetails(repairTimer)/1000)
if timeleft then
local 2ndString = " second to repair."
if timeleft > 1 then 2ndString = " seconds to repair."
end
if isPedInVehicle(localPlayer) then
outputChatBox("Time left: "..tostring(timeleft)..2ndString, 255, 255, 255, true)
end
return false
end
end
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
server.fixVehicle(vehicle)
outputChatBox("Vehicle fixed.", 255, 255, 255, true)
repairTimer = setTimer( function() repairTimer = false end, repairDelayTime, 1)
end
end
addCommandHandler('fix', repairVehicle)
--added this in attempt to reset the timer but doesnt really work
function resetTimer()
repairTimer = false
end
addEventHandler("onClientPlayerWasted", root, resetTimer)