Raised This Month: $ Target: $400
 0% 

few things about saving nicks(really important to me)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 06-01-2007 , 10:28   few things about saving nicks(really important to me)
Reply With Quote #1

in client_connect i want to grab that players nick, store it(only to memory), and when he connects again check if the same nick is stored, if yes - count to 4 more attempts and then ban(5 minutes), on each round start delete all the nicks stored

i really need this, pls help me guys
__________________
Voi is offline
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
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 06-01-2007 , 11:21   Re: few things about saving nicks(really important to me)
Reply With Quote #3

thx a lot, ive needed this couse ppl are just bashing with connects to get to my server
__________________
Voi is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-01-2007 , 14:36   Re: few things about saving nicks(really important to me)
Reply With Quote #4

I tested this and not working !...hum...
*I see you check if name was on server,but i don't see where you store the name..:/
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 06-01-2007 at 14:50.
Alka is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-01-2007 , 14:59   Re: few things about saving nicks(really important to me)
Reply With Quote #5

You do g_last_name_pos = 0 in logevent_round_start() but then you do this
Code:
for(new i=1; i<=g_last_name_pos; i++){
You get the idea... will NEVER execute that branch.
_Master_ is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-01-2007 , 15:05   Re: few things about saving nicks(really important to me)
Reply With Quote #6

yeah.... i<0 ...how should i make?
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-01-2007 , 15:26   Re: few things about saving nicks(really important to me)
Reply With Quote #7

I coded this in like 10 minutes and then checked with bots and it worked.
All names are stored in g_stored_names[MAX_NAMES+1][33] array (isn't it obvious? - look at name), lines:
Code:
g_last_name_pos += 1 copy(g_stored_names[g_last_name_pos], 32, name)
@_Master_:
You should analyze whole algorithm... I set g_last_name_pos = 0 in logevent_round_start() to reset names (g_last_name_pos==0 means no names stored). "for" loop is for linear search in g_stored_names array. If there are no names stored then it shouldnt start any search, instead it will store player name in first empty cell in g_stored_names array. On next connection attempts g_last_name_pos will be >=1, so it will start the search...
__________________
Impossible is Nothing
Sylwester is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-01-2007 , 15:57   Re: few things about saving nicks(really important to me)
Reply With Quote #8

hum...i tested my self,with server empty...that should be the problem!
__________________
Still...lovin' . Connor noob! Hello
Alka 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 10:31.


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