Trying to understand the antiflood plugin...
Greetings everybody,
I honestly don't know where to post this, since there aren't any sections for this type of questions. Also, I've searched about this and couldn't find an answer. This is a very... uhh.. basic question that you all may find absolutely hilarious, but: Before I started coding on my own I decided to learn from existing plugins, and started with a basic one, antiflood.amxx, which is included in AMXX already. Here's the code: PHP Code:
PHP Code:
Uhh... Don't make fun of me :oops: I've gone through the tutorials and have an understanding of pretty much everything they covered. Cheers |
Re: Trying to understand the antiflood plugin...
For the fact you can talk proper and I see a future here for you, I'll answer this when I get on my computer.
EDIT: Arkshine beat me to it. :sadface: |
Re: Trying to understand the antiflood plugin...
The player's index is passed into chkFlood() function. It's a callback from register_clcmd("say", "chkFlood"). This one registers a client command ( say/say_team, you are aware about them, right? ). So, when a player will say something chkFlood will be called and the player's index is passed into the callback. (You have just to write something in the function header, then you can use it. In this plugin you see "id", but you can write what you want).
You don't understand also what does the code ? |
Re: Trying to understand the antiflood plugin...
Quote:
PHP Code:
Cheers |
Re: Trying to understand the antiflood plugin...
Sorry. Will try to explain.
First read that, it explains what is an array : http://forums.alliedmods.net/showthr...t=94381#arrays Now, you are aware what does the plugin, it checks each time what you say and see if you chat too fastly or not.
To know if you flood you need to compare 2 times, the last time you have said something and the next time you have said something else. The game time is here as reference.
So, what does the code ? Forget the part with g_Flood for now. Code:
About g_Flood, its purpose is just to manage when the warning message should appear : Code:
Hope you understand better now, sorry I suck when It comes to explain something. |
Re: Trying to understand the antiflood plugin...
Ahh, thank you very much, I understood everything. Took me a while to realize why "id" was being used, but I got it.
I got confused, since I forgot that the first two times that the chkFlood() function is used it skips the if - else loop. Thank you and have a nice day :) |
| All times are GMT -4. The time now is 21:52. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.