Raised This Month: $ Target: $400
 0% 

Trying to understand the antiflood plugin...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2010 , 10:38   Re: Trying to understand the antiflood plugin...
Reply With Quote #5

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.
  • nexTime : contains the current game time, which is actually the number of seconds since the game has started.
  • maxChat : contains the value from the amx_flood_time cvar, it tells you how fast you can chat, so the time between 2 messages.

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.
  • g_Flooding : contains the next time you are allowed to say something. In others words, it will contain the current game time + the value from amx_flood_time cvar.
  • g_Flood : contains the number of times you flood. The more you flood the more you get the warning message.

So, what does the code ? Forget the part with g_Flood for now.

Code:
if (maxChat) {     //It retrieves the current game time     new Float:nexTime = get_gametime()         // It checks if the last time you have said something is > to the current game time.     // In others words, if the old game time + the flood time allowed is still > to the current game time.     // If so, it means you're going to flood.     // Example : old game time : 65, flood time allowed : 0.75, current game time : 65.2     //  => if ( 65 + 0.75 > 65.2 )       //  => Yes and you have to wait  65.75 - 65.2 = 0.55 second to be able to chat.     if (g_Flooding[id] > nexTime)     {         // If you are here, it means you flood.     }         // We update the last time for the next time the player will say something.     // Example : current game time : 65.2     //  => it means the next time you are allowed to chat will be at : 65.2 + 0.75 = 65.95     g_Flooding[id] = nexTime + maxChat }

About g_Flood, its purpose is just to manage when the warning message should appear :

Code:
if (maxChat) {     new Float:nexTime = get_gametime()         if (g_Flooding[id] > nexTime)     {         // If you are here, it means you flood.                 // If you have flooded 3 times in a row !         // Time to send a warning message.         if (g_Flood[id] >= 3)         {             client_print(id, print_notify, "** %L **", id, "STOP_FLOOD")                         // We update the next time a player is allowed to chat             // An extra of 3 seconds is added to calm down the guy.             g_Flooding[id] = nexTime + maxChat + 3.0                         // We stop there.             return PLUGIN_HANDLED         }                 // The player is flooding but it's not yet the third time in a row.         // We increase the count.         g_Flood[id]++     }         // The player doesn't flood right now. If the check true, it means he did it just a moment ago.     else if (g_Flood[id])     {         // But It's a good guy now, we decrease his number of floods.         g_Flood[id]--     }         g_Flooding[id] = nexTime + maxChat }

Hope you understand better now, sorry I suck when It comes to explain something.
__________________
Arkshine is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode