Apo Posted May 19, 2016 Share Posted May 19, 2016 hi please help me for set timer for my command if player use the command timer active for 60 sec and player can not use command timer active only for player no for everyone function consoleCreateMarker ( playerSource ) if ( playerSource ) then local x, y, z = getElementPosition ( playerSource ) createMarker ( x, y, z, "checkpoint", 2, 255, 0, 0, 255 ) outputChatBox ( "You got a red marker", playerSource ) end end addCommandHandler ( "createmarker", consoleCreateMarker ) Link to comment
roaddog Posted May 19, 2016 Share Posted May 19, 2016 local cooldown = {} function consoleCreateMarker ( playerSource ) if ( playerSource ) then if cooldown[playerSource] and isTimer(cooldown[playerSource]) then return outputChatBox("Spam protection 60 seconds", playerSource, 255, 0, 0) end local x, y, z = getElementPosition ( playerSource ) createMarker ( x, y, z, "checkpoint", 2, 255, 0, 0, 255 ) outputChatBox ( "You got a red marker", playerSource ) cooldown[playerSource] = setTimer(timerEnd, 60000, 1, playerSource) end end addCommandHandler ( "createmarker", consoleCreateMarker ) function timerEnd(player) if cooldown[player] and isTimer(cooldown[player]) then killTimer(cooldown[player]) cooldown[player] = nil end 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