S3Nn4oXx Posted September 10, 2015 Share Posted September 10, 2015 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 Link to comment
HUNGRY:3 Posted September 10, 2015 Share Posted September 10, 2015 look at the examples https://wiki.multitheftauto.com/wiki/GetTimerDetails Link to comment
JR10 Posted September 10, 2015 Share Posted September 10, 2015 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 Link to comment
S3Nn4oXx Posted September 10, 2015 Author Share Posted September 10, 2015 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 Link to comment
JR10 Posted September 10, 2015 Share Posted September 10, 2015 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) 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