Raised This Month: $ Target: $400
 0% 

Name Checker - help a bit!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
retribution
Member
Join Date: Nov 2007
Location: msk
Old 10-24-2009 , 23:57   Name Checker - help a bit!
Reply With Quote #1

Hi guys. I was trying to make a plugin with ability of name checking such as HLG has.

Here's what I got:

PHP Code:
 /*
    Another name checker. Duplicates HLG original functions of name checking cos this is only thing i need.

    CVARS:

    nm_namechecks 1 // Enables players name checking
    nm_namechanges 3 // How many name changes allowed (0 - infinite)
    nm_nametime 900.0 // Name changes within x seconds. MUST be float.

    Changelog

    24.10.2009 v1.0 Initial release

    Put cheaternames.ini file in your configs dir, or plugin will fail to load.

    Default cheaternames.ini contain:

; This is NameChecker database file. Feel free to add your own checks.
;
; Format is:
;
; "name" "flags" "message" "reason"
;
; Maxchars:
;
; name - 31
; flags - 2
; message 50
; reason -30
;
; Flag reference:
; k - Kick
; p - Log and Say and Ban 30 min
; q - Log, Say and Ban Permanently
;
; Checking reference:
;
; a - Name must contain any of characters
; b - Name must be equal to characters
;
; Examlpe
;
; "Player" "ka" "Player! Change nickname!" "[HLG]_Change_Nickname!"

; Unwanted names
"Player" "kb" "Player! Change nickname!" "[HLG] Change Nickname!"

; Cheaters
"Use_Cheat" "qb" "DIE CHEATING BASTARD!" "[HLG] Cheater detected"
"myg0t" "qa" "DIE CHEATING BASTARD!" "[HLG] Cheater detected"
"mygot" "qa" "DIE CHEATING BASTARD!" "[HLG] Cheater detected"

; Cheating clans
"4uTepbI" "qa" "DIE CHEATING BASTARD!" "[HLG] Cheating clans prohibited"
"FPTeam" "qa" "DIE CHEATING BASTARD!" "[HLG] Cheating clans prohibited"

*/

#include <amxmodx>
#include <amxmisc> 

// Uncomment to enable logging to file in configs dir
//#define LOG_TO_DIR 1
// Uncomment to enable debug messages. Logging must be enabled
//#define DEBUG_MODE 1

#define MAX_STRINGS 16
#define MAX_CHARS 128
#define DELAY 3.0
#define BANTIME 30
new const PREFIX[] = "HLG"
// Customization ends HERE. If you edit something below - unexpected behavior is possible.

#if defined LOG_TO_DIR
new NamesLog[200]
#endif
new MemoryString[MAX_STRINGS][MAX_CHARS], g_name[MAX_STRINGS][32], g_namekey[MAX_STRINGS][3], g_message[MAX_STRINGS][51], g_reason[MAX_STRINGS][31]
new 
cv_namecheckscv_namechangescv_nametime
new TotalNAMES
new Float:g_namechanged[33],Float:g_lastban[33], g_nccount[33], bool:g_verifyed[33]

public 
plugin_init()
{
    
register_plugin("NameChecker","1.0","Lethal")
    
cv_namechecks register_cvar"nm_namechecks""1" );
    
cv_namechanges register_cvar"nm_namechanges""3" );
    
cv_nametime register_cvar"nm_nametime""900.0" );
}

public 
plugin_cfg()
{
    new 
configsdir[200]
    new 
NamesFile[200]
    new 
NumNames 0

    get_configsdir
(configsdir,199)
#if defined LOG_TO_DIR
    
format(NamesLog199"%s/cheaternames.log"configsdir)
#endif
    
format(NamesFile,199,"%s/cheaternames.ini",configsdir)

    if (!
file_exists(NamesFile)) 
    {
        
server_print("[%s] Error: No %s found.",PREFIX,NamesFile)
        return 
PLUGIN_HANDLED;
    }
    
    
NumNames file_size(NamesFile,1
    new 
tempi
    TotalNAMES 
0
    
for(new i=0;i<NumNames;i++)
    {
        
MemoryString[TotalNAMES][0] = '^0'
        
read_file(NamesFile,i,MemoryString[TotalNAMES],MAX_CHARS,tempi)
    
        if (!
equal(MemoryString[TotalNAMES],"",strlen(MemoryString[TotalNAMES])) && (contain(MemoryString[TotalNAMES],";") == -1)) 
            
TotalNAMES++
    }

    new 
db_name[34], db_namekey[5], db_message[53], db_reason[33]
    
db_name[0] = '^0'
    
db_namekey[0] = '^0'
    
db_message[0] = '^0'
    
db_reason[0] = '^0'

    
for(new i=0;i<TotalNAMES;i++)
    {
        if (
strlen(MemoryString[i]) > MAX_CHARS
        {
            
server_print("[%s] Error: String in too long: %s."PREFIXMemoryString[i])
            return 
PLUGIN_HANDLED;
        }
        
parse(MemoryString[i],db_name,33,db_namekey,4,db_message,52,db_reason,32)
        
remove_quotes(db_name)
        
remove_quotes(db_namekey)
        
remove_quotes(db_message)
        
remove_quotes(db_reason)
        
copy(g_name[i], strlen(db_name), db_name)
        
copy(g_namekey[i], strlen(db_namekey), db_namekey)
        
copy(g_message[i], strlen(db_message), db_message)
        
copy(g_reason[i], strlen(db_reason), db_reason)
#if defined DEBUG_MODE
        
log_to_file(NamesLog"[%s] Reading ^"%s^" length %d."PREFIXMemoryString[i], strlen(MemoryString[i]))
        
log_to_file(NamesLog"[%s] Copy ^"%s^" ^"%s^" ^"%s^" ^"%s^"."PREFIXdb_namedb_namekeydb_messagedb_reason)
        
log_to_file(NamesLog"[%s] Result ^"%s^" ^"%s^" ^"%s^" ^"%s^"."PREFIXg_name[i], g_namekey[i], g_message[i], g_reason[i])
#endif
    
}

    
server_print("[%s] Loaded %d cheater names.",PREFIX,TotalNAMES)

    return 
PLUGIN_CONTINUE;
}

public 
client_putinserver(id)
{
    
g_namechanged[id] = get_gametime()
    
g_nccount[id] = 0
    g_verifyed
[id] = false;

    if(!
get_pcvar_num(cv_namechecks))
        return 
PLUGIN_CONTINUE;

    
set_task(DELAY"verify"id);

    return 
PLUGIN_CONTINUE;
}

public 
client_infochanged(id)
{
    new 
newname[32], oldname[32]
    
get_user_info(id"name"newname31)
    
get_user_name(idoldname31)

    if (!
equal(newnameoldname))
    {
        
g_verifyed[id] = false;

        if(
get_pcvar_num(cv_namechecks))
            
set_task(DELAY"verify"id);

        
g_namechanged[id] = get_gametime()
        
g_nccount[id]++
    }

    if (
get_pcvar_num(cv_namechanges) && (g_nccount[id] >= get_pcvar_num(cv_namechanges)) && (get_gametime() - g_namechanged[id] < get_pcvar_float(cv_nametime)))
    {
        new 
inf_message[41], inf_reason[61]
        
format(inf_message40"%d name changes in %d seconds",get_pcvar_num(cv_namechanges),get_pcvar_num(cv_nametime))
        
format(inf_reason60"[%s] Banned due to reaching changenames limit for %d min."PREFIXBANTIME)

        if (
get_gametime() - g_lastban[id] > 1.0)
        {
            new 
inf_userid get_user_userid(id)
            
server_cmd("amx_banip #%d %d ^"%s^""inf_useridBANTIMEinf_reason)
            
show_hudmessage(0"[%s] - Violation Detected:^nPlayer ^"%s^" violation ^"%s^"^nPunishment: Ban for %d minutes..."PREFIXnewnameinf_messageBANTIME)
            
g_lastban[id] = get_gametime()
#if defined LOG_TO_DIR
            
new inf_authid[32], inf_ip[32]
            
get_user_ip(idinf_ip311)
            
get_user_authid(idinf_authid31)
            
log_to_file(NamesLog"[%s] Banned ^"%s<%d><%s><>^" (IP ^"%s^") (minutes ^"%d^") (reason ^"%s^")"PREFIXnewnameinf_useridinf_authidinf_ipBANTIMEinf_reason)
#endif
        
}
    }

    return 
PLUGIN_CONTINUE;
}

public 
client_disconnect(id)
{
    
g_nccount[id] = 0
    g_verifyed
[id] = false;
}

public 
verify(id)
{
    if(!
is_user_connected(id) || g_verifyed[id])
        return 
PLUGIN_CONTINUE;
    
    
set_hudmessage(20010000.050.6520.026.00.010.12)

    new 
name[32], ij;
    
get_user_name(idname31);
#if defined DEBUG_MODE
    
log_to_file(NamesLog"[%s] Verify ^"%s^"."PREFIXname)
#endif

    
for(0sizeof(g_name); i++)
    {
        if(
containi(nameg_name[i][j]) != -1)
        {
#if defined DEBUG_MODE
            
log_to_file(NamesLog"[%s] ^"%s^" match with ^"%s^"."PREFIXnameg_name[i])
#endif
            
if((containi(g_namekey[i], "b") != -1) && !equal(g_name[i], name))
                return 
PLUGIN_CONTINUE
#if defined DEBUG_MODE
            
log_to_file(NamesLog"[%s] ^"%s^" equal with ^"%s^"."PREFIXnameg_name[i])
#endif
            
new v_userid get_user_userid(id)
            if(
containi(g_namekey[i], "k") != -1)
            {
                
                
server_cmd("amx_kick #%d ^"%s^""v_useridg_reason[i])
                
show_hudmessage(0"[%s] - Violation Detected:^nPlayer ^"%s^" violation ^"%s^"^nPunishment: KIKC..."PREFIXnameg_message[i])
#if defined LOG_TO_DIR
                
new v_authid[32], v_ip[32]
                
get_user_ip(idv_ip311)
                
get_user_authid(idv_authid31)
                
log_to_file(NamesLog"[%s] Kicked ^"%s<%d><%s><>^" (IP ^"%s^") (reason ^"%s^")"PREFIXnamev_useridv_authidv_ipg_reason[i])
#endif
            
}
            else if((
containi(g_namekey[i], "p") != -1) && (get_gametime() - g_lastban[id] > 1.0))
            {
                
server_cmd("amx_banip #%d %d ^"%s^""v_useridBANTIMEg_reason[i])
                
show_hudmessage(0"[%s] - Violation Detected:^nPlayer ^"%s^" violation ^"%s^"^nPunishment: Ban for %d minutes..."PREFIXnameg_message[i], BANTIME)
                
g_lastban[id] = get_gametime()
#if defined LOG_TO_DIR
                
new v_authid[32], v_ip[32]
                
get_user_ip(idv_ip311)
                
get_user_authid(idv_authid31)
                
log_to_file(NamesLog"[%s] Banned ^"%s<%d><%s><>^" (IP ^"%s^") (minutes ^"%d^") (reason ^"%s^")"PREFIXnamev_useridv_authidv_ipBANTIMEg_reason[i])
#endif
            
}
            else if((
containi(g_namekey[i], "q") != -1) && (get_gametime() - g_lastban[id] > 1.0))
            {
                
server_cmd("amx_punch #%d 0"v_userid)
                
show_hudmessage(0"[%s] - Violation Detected:^nPlayer ^"%s^" violation ^"%s^"^nPunishment: Banned PERMANENTLY..."PREFIXnameg_message[i])
                
g_lastban[id] = get_gametime()
#if defined LOG_TO_DIR
                
new v_authid[32], v_ip[32]
                
get_user_ip(idv_ip311)
                
get_user_authid(idv_authid31)
                
log_to_file(NamesLog"[%s] Banned ^"%s<%d><%s><>^" (IP ^"%s^") (minutes ^"0^") (reason ^"%s^")"PREFIXnamev_useridv_authidv_ipg_reason[i])
#endif
            
}
            else
            {
                
server_print("[%s] Error: No proper action for ^"%s^"! ^"%s^" found."PREFIXg_name[i], g_namekey[i])
            }
        }
    }
    
g_verifyed[id] = true;

#if defined DEBUG_MODE
    
log_to_file(NamesLog"[%s] ^"%s^" verifyed successfully."PREFIXname)
#endif
    
return PLUGIN_CONTINUE;

On tests it works just fine, but i want to add one feature, that i tryed to add several times and failed. If player changes name more then 3 times in 900 secs he got banned. I want this plugin to verify each namechange and if third namechange got something like "Use Cheat" ban player permanently. Now this plugins bans only for 30 mins

I tryed modify this:
PHP Code:
        new inf_message[41], inf_reason[61]
        
format(inf_message40"%d name changes in %d seconds",get_pcvar_num(cv_namechanges),get_pcvar_num(cv_nametime))
        
format(inf_reason60"[%s] Banned due to reaching changenames limit for %d min."PREFIXBANTIME)

        if (
get_gametime() - g_lastban[id] > 1.0)
        {
            new 
inf_userid get_user_userid(id)
            
server_cmd("amx_banip #%d %d ^"%s^""inf_useridBANTIMEinf_reason
to this

PHP Code:
        new inf_message[41], inf_reason[61]
        
format(inf_message40"%d name changes in %d seconds",get_pcvar_num(cv_namechanges),get_pcvar_num(cv_nametime))
        
format(inf_reason60"[%s] Banned due to reaching changenames limit for %d min."PREFIXBANTIME)

        if (
get_gametime() - g_lastban[id] > 1.0 && g_verifyed[id])
        {
            new 
inf_userid get_user_userid(id)
            
server_cmd("amx_banip #%d %d ^"%s^""inf_useridBANTIMEinf_reason
But that stopped namechange ban at all cos g_verifyed[id] always false. Can you help me optimize this plugin cos im a newbie and add this mighty feature?
Attached Files
File Type: ini cheaternames.ini (963 Bytes, 103 views)
File Type: sma Get Plugin or Get Source (dragons_namecheck.sma - 536 views - 9.0 KB)
__________________



Last edited by retribution; 10-25-2009 at 00:00.
retribution is offline
Send a message via ICQ to retribution
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-25-2009 , 01:29   Re: Name Checker - help a bit!
Reply With Quote #2

I don't have time to search for it right now, nor do I recall the name of it, but I do know there's a plugin that does this already. I believe JGHG wrote it. That's his name abbreviated. Don't recall either how he spelled it.

Maybe I gave enough clues that someone else can point you to it, or perhaps you can find it yourself.
__________________
Brad is offline
retribution
Member
Join Date: Nov 2007
Location: msk
Old 10-25-2009 , 08:28   Re: Name Checker - help a bit!
Reply With Quote #3

You mean http://forums.alliedmods.net/showthread.php?t=8349 ?
It cannot compare names with list of forbidden names and ban cheaters, so this plugin is useless in my case.
__________________


retribution is offline
Send a message via ICQ to retribution
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-25-2009 , 10:41   Re: Name Checker - help a bit!
Reply With Quote #4

Yeah, that's the one I was thinking of.

It sounds like you're trying to have a plugin do two things. Seems like you want both flood control, which JGHG's plugin provides, and specific name restriction which is something my Restrict Names plugin does, as well as a few others here.

Am I missing what you're really going for?
__________________
Brad is offline
retribution
Member
Join Date: Nov 2007
Location: msk
Old 10-25-2009 , 12:53   Re: Name Checker - help a bit!
Reply With Quote #5

No flood control, just namechanges control and restrict some names. I want plugin with HLGuard nameban features. So it must just ban cheaters with specified name (several actions -kick/ban) and control name changes.

I need this cos i use only this feature from HLGuard. If i duplicate it in a plugin i can disable HLG at all.

I looked at restrict names plugins and borrowed some code, but they cannot provide features like my versiod does. There is only thing i have to add - check last namechange and compare with cheaters list BEFORE banning for too fast namechanging. And fix possible bugs.

Can you look at my code? Mb you will find a solution for my problem....
__________________


retribution is offline
Send a message via ICQ to retribution
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-25-2009 , 13:09   Re: Name Checker - help a bit!
Reply With Quote #6

I'm sorry, still not clear on what you want.

So, you don't care that they are changing their name repeatedly, right? You just want them to be banned when it gets changed to a specific name?
__________________
Brad is offline
retribution
Member
Join Date: Nov 2007
Location: msk
Old 10-25-2009 , 19:33   Re: Name Checker - help a bit!
Reply With Quote #7

Quote:
So, you don't care that they are changing their name repeatedly, right? You just want them to be banned when it gets changed to a specific name?
No, i want both this features.

We got situations:

1. Player "0" connecting to server. Player changed name to "1", to "2", to "3", then banned for 30 minutes - that works perfectly.

2. Player "0" connecting to server. Player changed name to "Use_Cheat", then banned permanently. If player connect with name "Use_Cheat" he will get same ban. This works too. (name and action by config file)

the bug! 3. Player "0" connecting to server. Player changed name to "1", to "2", to "Use_Cheat", then banned for 30 minutes cos namechanges check work faster then verify function! I want ban by config rules in this case too!
I tryed to make delayed check for namechanges and delayed ban but got missing "reason" field and other mystical errors...
__________________


retribution is offline
Send a message via ICQ to retribution
retribution
Member
Join Date: Nov 2007
Location: msk
Old 10-27-2009 , 15:36   Re: Name Checker - help a bit!
Reply With Quote #8

I solved this! Should i post the plugin? Are there many plugins with such functions?
__________________


retribution is offline
Send a message via ICQ to retribution
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 17:42.


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