Raised This Month: $ Target: $400
 0% 

Check character then replace


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Syturi0
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
Old 04-13-2016 , 14:32   Check character then replace
Reply With Quote #1

I want to only allow A-Z, 0-9, and a few special characters like [](),.-~#=+-, on nicknames.

PHP Code:
new const g_AllowNickCharacter [][] =
{
    
"a""b""c""d""e""f""g""h""i",
    
"j""k""l""m""n""o""p""q""r",
    
"s""t""u""v""x""z""<"">"",",
    
"+""*""'""?""="")""(""/""#",
    
".""-"";"":""_""ç""~""",
    
"!""|""\", "[", "]", "1", "2", "3", "4",
    "
5", "6", "7", "8", "9", "0", "@"

If the player uses a character that is not one of those mentioned above, it will get removed.
This is a test i did, its only for the first character:
PHP Code:
public client_infochanged(id)
{
    if(!
is_user_bot(id) && !is_user_hltv(id))
    {
        new const 
name[] = "name"
        
new szNewName[33]
        
get_user_info(idnameszNewNamecharsmax(szNewName))

        for(new 
0sizeof(g_AllowNickCharacter); i++)
            if(!(
equal(szNewName[0], g_AllowNickCharacter[i]) != -1))
                    
replace(szNewNamecharsmax(szNewName), szNewName[0], "")

        
set_user_info(idnameszNewName)
    }

Whats wrong?

Last edited by Syturi0; 04-13-2016 at 14:35.
Syturi0 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 18:36.


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