Isaias1999 Posted November 29, 2018 Share Posted November 29, 2018 Hi,i'm new here ,and i'm noob ,i wanna know how to put a time of 3 minutes to get this command what i gave of this forum ,i wanna know then i can put that and the player could'nt abuse of this command ,i'm going to leave this ,please help me (sorry for mi noob english) function fix (playerSource) local theVehicle = getPedOccupiedVehicle (playerSource) if theVehicle and getVehicleController ( theVehicle ) == playerSource then fixVehicle (theVehicle) outputChatBox ("Your vehicle has been repaired !" , thePlayer) end end addCommandHandler ("repair" , fix) Link to comment
iDannz [Breno] Posted February 4, 2019 Share Posted February 4, 2019 (edited) this isnt the correct page to do this ask, but you can try to use setTimer like this timer = {} --\\ create a table for all timers function fix (playerSource) if isTimer(timer[playerSource]) then return outputChatBox("Wait just a litte.",playerSource) end --\\ send an error msg to player, if he is spamming local interval = 15000 --\\ set up the interval in milliseconds local theVehicle = getPedOccupiedVehicle (playerSource) if theVehicle and getVehicleController ( theVehicle ) == playerSource then fixVehicle (theVehicle) outputChatBox ("Your vehicle has been repaired !" , thePlayer) timer[playerSource] = setTimer(function(playerSource) --\\ finally create the timer when player type the command. timer[playerSource] = nil end,interval,1,playerSource) end end addCommandHandler ("repair" , fix) Edited February 4, 2019 by iDannz Link to comment
Feche1320 Posted February 7, 2019 Share Posted February 7, 2019 With getTickCount() the script is more efficient: local SECONDS = 20 -- 20 seconds between command use local tick = {} function fix(playerSource) local theVehicle = getPedOccupiedVehicle(playerSource) if theVehicle and getVehicleController ( theVehicle ) == playerSource then if getTickCount() - (tick[playerSource] or 0) >= SECONDS * 1000 then fixVehicle (theVehicle) tick[playerSource] = getTickCount() outputChatBox ("Your vehicle has been repaired !" , thePlayer) else outputChatBox ("Don't abuse the command!" , thePlayer) end end end addCommandHandler("repair" , fix) Change 'SECONDS' variable to whatever you need. 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