Raised This Month: $ Target: $400
 0% 

plugin improvement - anti name flood


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ehha
SourceMod Donor
Join Date: Apr 2006
Location: Sibiu
Old 02-16-2009 , 19:20   Re: plugin improvement - anti name flood
Reply With Quote #1

Bump!
So i made no mistakes? Nothing to improve? Just tell me and I'll move along
__________________
ehha is offline
Speed!
BANNED
Join Date: Jan 2009
Old 02-16-2009 , 19:58   Re: plugin improvement - anti name flood
Reply With Quote #2

Quote:
Originally Posted by ehha View Post
Bump!
So i made no mistakes? Nothing to improve? Just tell me and I'll move along
rewrote for you
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "name flood"
#define VERSION "0.1"
#define AUTHOR "camper"
#define ID_FLOOD (taskid - TASK_FLOOD)
//#pragma semicolon 1 useless :(

enum (+= 100)
{
    
TASK_FLOOD
}

new 
ct[33], nft;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
nft register_cvar("amx_name_flood_time""20");
}

public 
client_putinserver(id)
{
    
set_task(nft"decrease_flood"id+TASK_FLOOD)
    
ct[id] = 0;
}

public 
decrease_flood(taskid)
{
    if (
ct[ID_FLOOD] > 0)
        
ct[ID_FLOOD]  -= 1
    set_task
(nft"decrease_flood"ID_FLOOD+TASK_FLOOD)
}

public 
client_disconnect(id)
{
    
remove_task(id+TASK_FLOOD)
}

public 
client_infochanged(id)
{
    new 
newname[32], oldname[32];
    
get_user_info(id"name"newname,31);
    
get_user_name(idoldname31);
        
    if(
equal(newnameoldname))
        return 
PLUGIN_HANDLED;
    
    
ct[id]++
    switch (
ct[id])
    {
        case 
3:
        {
            
client_print(idprint_chat"*** Nick change flood! Stop or you will be kicked! ***");
            
client_print(idprint_chat"*** Nick change flood! Stop or you will be kicked! ***");
        }
        case 
4:
        {
            
server_cmd("kick #%d ^"%s^""get_user_userid(id), "Kicked due to name change flood.");
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_HANDLED

look at the changes, how simple is now, and how better (using tasks for decreasing flood count, and removing them.)
Speed! is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-16-2009 , 20:49   Re: plugin improvement - anti name flood
Reply With Quote #3

@Speed!

PHP Code:
set_task(nft"decrease_flood"id+TASK_FLOOD
ntf is a cvar pointer not a floating point number, you can't use it there.
fysiks is offline
Reply



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 01:39.


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