How to limit a command to usage every x minutes
Could somebody share an example of limiting a client chat command to only once every minute?
Trying to figure this out with and without a timer... w.e is easier. Something like if somebody uses = /health it would be blocked from usage by everyone in the server for a a minute with a message like, you must wait x amount b4 you can use this command again |
Re: How to limit a command to usage every x minutes
Store get_systime() in a global variable each time the command is executed. Before actually executing the command, check if get_systime() minus the stored time is greater than 60 (seconds). If it is, execute the command, otherwise, don't execute the command and optionally print a message explaining why the command wasn't executed.
This is quite a simple concept so I'd recommend that you try it out yourself. If you can't get it to work after trying to write the code yourself, the code that you tried and we can help you fix it. P.S. threads in the "Code Snippets/Tutorials" forum, are either code snippets or tutorials, not requests for anything. Since you are looking for scripting help, you should post this in Scripting Help. I reported the post so maybe a moderator will move it for you. |
Re: How to limit a command to usage every x minutes
Sorry for the wrong section.
So well.. I managed to put a working version of it up I just copy and paste things around here lol.. but it's only limiting it for the player who typed the command.. was thinking the first person to type it.. is the one that executes it and then it would be blocked for 2 minutes for everyone else. It's looking like this: How to make it just block the command from being used during that cooldown period, with a message saying "You must wait X, amount before you can advertise again" Code:
#include <amxmodx> |
Re: How to limit a command to usage every x minutes
Quote:
|
Re: How to limit a command to usage every x minutes
change the last_used array to an integer if you want the command get blocked globally for everyone
|
Re: How to limit a command to usage every x minutes
Quote:
|
Re: How to limit a command to usage every x minutes
Yeah, I thought it was done the way fysiks mentioned. I honestly look around on google, and the amxx wiki to figure out how to get any of this to work as I don't really know much about it..
But I'm still stuck with making it block EVERYONE. Some1 mentioned up to turn the last_used array into an integer not really sure how I'd do this as I'm total noob at this stuff lol |
Re: How to limit a command to usage every x minutes
Quote:
Quote:
|
Re: How to limit a command to usage every x minutes
Yeah it works perfectly but what it's doing is only limiting the player that wrote it. So everyone can write it.. which can spam server. Would be nice to just let it execute once every x amount and be blocked for anyone to use for that time period
|
Re: How to limit a command to usage every x minutes
Remove [33] and [id].
|
All times are GMT -4. The time now is 08:52. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.