Raised This Month: $ Target: $400
 0% 

Trying to understand the antiflood plugin...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
hristosax
Junior Member
Join Date: Jul 2008
Old 08-23-2010 , 17:47   Trying to understand the antiflood plugin...
Reply With Quote #1

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:
new Float:g_Flooding[33] = {0.0, ...}
new 
g_Flood[33] = {0, ...}

new 
amx_flood_time;

public 
plugin_init()
{
    
register_plugin("Anti Flood"AMXX_VERSION_STR"AMXX Dev Team")
    
register_dictionary("antiflood.txt")
    
register_clcmd("say""chkFlood")
    
register_clcmd("say_team""chkFlood")
    
amx_flood_time=register_cvar("amx_flood_time""0.75")
}

public 
chkFlood(id)
{
    new 
Float:maxChat get_pcvar_float(amx_flood_time)

    if (
maxChat)
    {
        new 
Float:nexTime get_gametime()
        
        if (
g_Flooding[id] > nexTime)
        {
            if (
g_Flood[id] >= 3)
            {
                
client_print(idprint_notify"** %L **"id"STOP_FLOOD")
                
g_Flooding[id] = nexTime maxChat 3.0
                
return PLUGIN_HANDLED
            
}
            
g_Flood[id]++
        }
        else if (
g_Flood[id])
        {
            
g_Flood[id]--
        }
        
        
g_Flooding[id] = nexTime maxChat
    
}

    return 
PLUGIN_CONTINUE

I came across this:
PHP Code:
if (maxChat)
    {
        new 
Float:nexTime get_gametime()
        
        if (
g_Flooding[id] > nexTime)
        {
            if (
g_Flood[id] >= 3)
            {
                
client_print(idprint_notify"** %L **"id"STOP_FLOOD")
                
g_Flooding[id] = nexTime maxChat 3.0
                
return PLUGIN_HANDLED
            
}
            
g_Flood[id]++ 
And I'm just struggling to understand how "id" (which I believe is the player index) fits into this and how this all works. It just doesn't make sense to me and I've had previous experience with programming. The whole sequence just seems illogical.

Uhh... Don't make fun of me

I've gone through the tutorials and have an understanding of pretty much everything they covered.


Cheers
hristosax 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