Samking Posted September 7, 2018 Posted September 7, 2018 (edited) How I can set the time to command for example if I type /givemecash command I will not able to use this command again before 30 mins. How I can do this? Edited September 7, 2018 by Samking
Mqtyx Posted September 7, 2018 Posted September 7, 2018 (edited) As soon as the player types the command, you can store the tick count at this time and then based on that, you can check later whether the player used the command before the last 30 minutes. An example: local antiSpam = { } function someCommandHandler(plr) local lastCheck = antiSpam[plr] local currentTick = getTickCount() if (lastCheck and (currentTick - lastCheck) < (30 * 60000)) then -- Unless lastCheck is nil, get the current tick and subtract from it the last time the player used the command then check whether the result is smaller than 30 minutes and if so, return return false end antiSpam[plr] = currentTick -- Updates the antiSpam table with the new info -- Do whatever you want end addCommandHandler("somecommand", someCommandHandler) Edited September 7, 2018 by Mqtyx
Samking Posted September 8, 2018 Author Posted September 8, 2018 16 hours ago, Mqtyx said: As soon as the player types the command, you can store the tick count at this time and then based on that, you can check later whether the player used the command before the last 30 minutes. An example: local antiSpam = { } function someCommandHandler(plr) local lastCheck = antiSpam[plr] local currentTick = getTickCount() if (lastCheck and (currentTick - lastCheck) < (30 * 60000)) then -- Unless lastCheck is nil, get the current tick and subtract from it the last time the player used the command then check whether the result is smaller than 30 minutes and if so, return return false end antiSpam[plr] = currentTick -- Updates the antiSpam table with the new info -- Do whatever you want end addCommandHandler("somecommand", someCommandHandler) Not working
Samking Posted September 11, 2018 Author Posted September 11, 2018 On 08/09/2018 at 07:29, KINGKHAN said: Use timer function I am newbie please can you make on as an example
Dimos7 Posted September 11, 2018 Posted September 11, 2018 20 minutes ago, Samking said: I am newbie please can you make on as an example no
MIKI785 Posted September 12, 2018 Posted September 12, 2018 22 hours ago, Samking said: I am newbie please can you make on as an example An example utilising getTickCount (better than setTimer) was already posted, so work with that.
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