View Single Post
Author Message
Snake.
Senior Member
Join Date: Jul 2017
Old 02-10-2019 , 06:40   [EDIT REQ] Block/Allow some characters on names
Reply With Quote #1

It only allows A-Z and numbers on names but i want to allow $, &, %, /, (, ) etc... How can i do ?

PHP Code:
#include <amxmodx>

#define PLUGIN        "No-Spl Chars InName"
#define VERSION        "1.0"
#define AUTHOR        "Shooting King"


public plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
}

public 
client_putinserver(idCheckName(idtrue);

public 
client_infochanged(idCheckName(idfalse);

public 
CheckNameidbool:bShowMsg )
{
    static 
ijszName[33], szNewName[33], len;
    
    
len 0;
    
szName[0] = '^0';
    
szNewName[0] = '^0';
    
    
get_user_info(id"name"szName33);
    
len strlen(szName);
    
// log_amx( "Checking.... %s[%d] ", szName, len );
    
    
for( 0leni++ )
    {
        if( (
szName[i] > 47 &&  szName[i] < 58) ||  // Numbers from 1, 2, ...., 0
            
(szName[i] > 64 &&  szName[i] < 91) ||    // Chars from A, B, C, ...., Z
            
(szName[i] > 96 &&  szName[i] < 123) || // Chars from a, b, c, ...., z
            
(szName[i] == ' ') )
        {
            
// log_amx( "a Valid Char.... %c[%d] ", szName[i], i );
            
szNewName[j] = szName[i];
            
j++;
        }
        else
        {
            
// log_amx( "Not a Valid Char.... %c[%d] ", szName[i], i );
            
continue;
        }
    }
    
    if( 
33 szNewName[j] = '^0';    
    
set_user_info(id,"name",szNewName); 
    
    if( 
bShowMsg )
    {
        
client_print0print_chat"Player with original nickname ^"%s^"[%s] joined the game."szNameszNewName );
    }

Snake. is offline
Send a message via Skype™ to Snake.