Raised This Month: $ Target: $400
 0% 

few things about saving nicks(really important to me)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-01-2007 , 11:14   Re: few things about saving nicks(really important to me)
Reply With Quote #2

I really dunno why do you need this, but anyway here is code of this simple plugin:

PHP Code:
#include <amxmodx>

#define MAX_NAMES 100
#define MAX_ATTEMPTS 4

new g_stored_names[MAX_NAMES+1][33]
new 
g_attempts[MAX_NAMES+1]
new 
g_last_name_pos 0  //indicates "last used cell" in g_stored_names array

public plugin_init(){
    
register_plugin"BanOn5thAttempt""1.0""Sylwester" )
    
register_logevent("logevent_round_start"2"1=Round_Start")
}

public 
logevent_round_start(){
    
g_last_name_pos 0  //no names stored in array
}

public 
check_name(id){
    new 
name[33]
    
get_user_name(idname32)
    for(new 
i=1i<=g_last_name_posi++){  //search g_stored_names array for specified name (if any stored)
        
if(equal(g_stored_names[i], name)){
            
g_attempts[i] += 1  //name has been found, increase amount of attempts for player with this name by 1
            
if(g_attempts[i] > MAX_ATTEMPTS){  //check if player exceeded the limit
                
g_attempts[i] = 0  //reset amount of attempts, so another player with same name will not be banned instantly

                // insert ban code here
                // ban player with id "id"
            
}
            return 
PLUGIN_CONTINUE
        
}
    }

    if(
g_last_name_pos >= MAX_NAMES)
        return 
PLUGIN_CONTINUE  //don't store any more names if reached the limit

    
g_last_name_pos += 1  //set "last used cell" to "first empty cell"
    
copy(g_stored_names[g_last_name_pos], 32name)  //store player name in "first empty cell"
    
g_attempts[g_last_name_pos] = 1
    
    
return PLUGIN_CONTINUE
}

public 
client_connect(id){
    
check_name(id);

__________________
Impossible is Nothing

Last edited by Sylwester; 06-01-2007 at 15:58. Reason: added comments
Sylwester 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 10:31.


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