Limit for a command
How would you create a limit for a command?
Example: If I wanted to put a limit on the number of times someone can say /blah per round, how would I do that? |
Re: Limit for a command
I think with this:
PHP Code:
|
Re: Limit for a command
But, that's not putting a limit on the number of times someone can use that command.
|
Re: Limit for a command
Use return PLUGIN_HANDLED. The only catch is your blocker plugin must be placed before the plugin containing the function in plugins.ini
Tested with my aimbot detection plugin plugins.ini: Code:
thisplugin.amxxPHP Code:
|
Re: Limit for a command
I don't get how that works - it seems like you're only creating a variable and then checking if it is greater than or equal to 3.
Explain, please? |
Re: Limit for a command
In this example I am creating a function to react when a console command is called, just as you normally do when creating a plugin. In this case, we want to block the "amx_aimwatch" command from being called after 3 times so we return PLUGIN_HANDLED in the blocker plugin. Console commands hit the list of plugins in order as listed in plugins.ini so as long as we place the blocker plugin before the plugin containing the function then we can prevent it from reaching the function plugin.
|
Re: Limit for a command
Ah, I get it now! Thank you.
|
Re: Limit for a command
I wouldn't recommend putting a ++ in a conditional statement... I just think it makes the code a little harder to follow at no benefit.
|
Re: Limit for a command
Quote:
|
Re: Limit for a command
Is there any proof of the actual machine cycles on that? Wouldn't a for loop compared to a while be slower because the ++ is applied separately from the comparison? I've never seen anyone refer to this as an optimization... links for Bad_Bud please?
If you change a variable and try to compare it immediately afterward, isn't that going to create a stall anyway? |
| All times are GMT -4. The time now is 15:11. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.