Jump to content

Time to wait


S3Nn4oXx

Recommended Posts

Posted

Hello guys can you show me example of setTimer, I mean when i do in the first time the command /cmdname

then it shows me the remaining time

Thanks

Sorry for all the questions i just want to learn Lua :)

Posted
Remaining time of the timer's next execution, getTimerDetails? Please explain.

The wiki page has an example already.

setTimer(function() 
 -- code 
end, 5000, 1) -- 5 seconds 

JR10? I mean When i type the command in the first time I dont need to wait, and when i do in the second time so i need to wait

Posted

Store the tick count in a table and check to see if the time is long enough:

local anti_spam_tick = {} 
  
addCommandHandler('/cmdname', function(player) 
 if (not anti_spam_tick[player] or (anti_spam_tick[player] and getTickCount() - anti_spam_tick[player] > 5000) --[[ 5 seconds ]]) then 
  anti_spam_tick[player] = getTickCount() 
  -- do something 
 else 
  outputChatBox('You must wait 5 seconds', player) 
 end 
end) 

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