DarkByte Posted February 14, 2016 Share Posted February 14, 2016 Hey can someone explain me how to use getTimerDetails i made this but cant understand whats wrong. timer = {} --------------------------- -- Repair vehicle --------------------------- function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then if not isTimer(timer[g_Me]) then timer[g_Me] = setTimer(function() timer[g_Me] = nil end,30000,1) server.fixVehicle(vehicle) outputChatBox("#006400• Vehicle successfully repaired", 0, 100, 0,true) else errMsg("• Please wait at least "..getTimerDetails(timer).." seconds before repairing again.") end end end addCommandHandler('repair', repairVehicle) addCommandHandler('rp', repairVehicle Link to comment
Mr_Moose Posted February 14, 2016 Share Posted February 14, 2016 The syntax looks like this: int, int, int getTimerDetails ( timer theTimer ) So you have to load the data returned by that function into variables before you can use any of it, like this: local time_left_ms, executes_lesft, total_executes_count = getTimerDetails(timer[g_Me]) Wiki has a pretty good explaination of all this stuff: getTimerDetails Link to comment
HappyMeal Posted February 14, 2016 Share Posted February 14, 2016 Like this timer = {} --------------------------- -- Repair vehicle --------------------------- function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then if not isTimer(timer[g_Me]) then -- local remaining, executesRemaining, totalExecutes = getTimerDetails(timer) timer[g_Me] = setTimer(function() timer[g_Me] = nil end,30000,1) server.fixVehicle(vehicle) local time_left_ms, executes_lesft, total_executes_count = getTimerDetails(timer[g_Me]) if (remaining and executesRemaining and totalExecutes) then outputChatBox("#006400• Vehicle successfully repaired", 0, 100, 0,true) else errMsg("• Please wait at least "..time_left_ms.." seconds before repairing again.") end end end end addCommandHandler('repair', repairVehicle) addCommandHandler('rp', repairVehicle) Link to comment
HappyMeal Posted February 14, 2016 Share Posted February 14, 2016 Like this timer = {} --------------------------- -- Repair vehicle --------------------------- function repairVehicle() local vehicle = getPedOccupiedVehicle(g_Me) if vehicle then if not isTimer(timer[g_Me]) then -- local remaining, executesRemaining, totalExecutes = getTimerDetails(timer) timer[g_Me] = setTimer(function() timer[g_Me] = nil end,30000,1) server.fixVehicle(vehicle) local time_left_ms, executes_lesft, total_executes_count = getTimerDetails(timer[g_Me]) if (remaining and executesRemaining and totalExecutes) then outputChatBox("#006400• Vehicle successfully repaired", 0, 100, 0,true) else errMsg("• Please wait at least "..time_left_ms.." seconds before repairing again.") end end end end addCommandHandler('repair', repairVehicle) addCommandHandler('rp', repairVehicle) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now