Limit uses
Alright, I know this is simple but I'm not sure how to do it. Say I'd want to limit the use of a certain command to 3 times per round, how would I do this?
|
its quite simple actually.
1. Hook the command to a function 2. Make an array that will hold everyones 'command status' like new timesused[32] 3. When the command is ran, use an if statement to see if timesused[id] >= 3. Then return PLUGIN_HANDLED. (optional: write a client_print or do somethign more advanced) 4. then do an else statement 5. timesused[id]++ 6. Do what ever the command ussually does; or return PLUGIN_CONTINUE if its a command that is built into HL. 7. You can either use logevent or just event to hook a new round or ResetHud, which will then run a function that does Code:
for (new i = 0; i<sizeof(timesused);i++){ |
So.. somethin like this..
Code:
|
Code:
also to reset the commadn count every round Code:
however, someoen can reset their command usage by typing fullupdate in console. you might want to block that. |
Alright, thanks..
Yea, I'll block that.. =] |
Player indexes are from 1 - 32.
An array with a size of 32 has indexes from 0 - 31. You could possibly get an out-of-bounds error. Declare your array with a size of 33. |
Will do.
|
well typo, besides i never play with a max 32 server anyway.
|
But that doesn't mean the people running your plugins don't. :-P
|
there is a rare amount of servers (well comparted to the total of all servers) that run max 32, and if someone did, whats the chance of them choosing one of my plugins? :D
even though i know i should use [33].. |
| All times are GMT -4. The time now is 14:06. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.