Jump to content

help


Apo

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...