Raised This Month: $ Target: $400
 0% 

Invalid Character in Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
owned
Member
Join Date: Jul 2007
Old 12-24-2007 , 17:45   Invalid Character in Name
Reply With Quote #1

What i'm trying to do is, if the user has ` or ~ in their name it kicks them with a message.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Bad Name Kicker"
#define VERSION "1.0"
#define AUTHOR "owned"

new const bad_names[][] = {"`","~"};


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
client_connect(id){
    new 
name[32];
    
get_user_name(id,name,31);
    
    
checkname(id);
    return 
PLUGIN_CONTINUE;
}

public 
client_infochanged(id){
    new 
name[32];
    
get_user_name(id,name,31);
    
    
checkname(id);
    return 
PLUGIN_CONTINUE;
}

public 
checkname(id){
    new 
name[32];
    
get_user_name(id,name,31);
    new 
uid get_user_userid(id);
    
    if(
is_user_admin(id)){
        return 
PLUGIN_CONTINUE;
    }else {
        for(new 
0sizeof bad_namesi++){
            if(
contain(name,bad_names[i]) > 0){
                
kickuser(uid);
                return 
PLUGIN_CONTINUE;
            }
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
kickuser(id){
    new 
name[32];
    
get_user_name(id,name,31);
    
    
server_cmd("banid 1 #%d"id);
    
client_cmd(id"echo ^"[BNKYour name contained invalid characters!^"; disconnect");
    return 
PLUGIN_CONTINUE;

Well I guess it doesn't want to kick me. Can I get some help?
__________________
MARREC/OWNED = me.
owned is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-24-2007 , 17:47   Re: Invalid Character in Name
Reply With Quote #2

To start with...
Code:
new const bad_names[][] = {"`","~"};
-->
Code:
new const bad_names[] = {'`','~'};

Then...
Code:
public checkname(id){     new name[32];     get_user_name(id, name, 31);     new uid = get_user_userid(id);     new len = strlen(name);         if ( is_user_admin(id) )         return PLUGIN_CONTINUE;         for ( new i = 0 ; i < sizeof bad_names - 1 ; i++ ) {         for ( new j = 0 ; j < len ; j++ ) {             if ( name[j] == bad_names[i] ) {                 kickuser(uid);                 return PLUGIN_CONTINUE;             }         }     }     return PLUGIN_CONTINUE; }

Last edited by [ --<-@ ] Black Rose; 12-24-2007 at 17:51.
[ --<-@ ] Black Rose is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-24-2007 , 17:59   Re: Invalid Character in Name
Reply With Quote #3

Also, there is no point in getting the client's name in connect and infochanged if you don't use it
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou 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 11:05.


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