Jump to content

No colorcode on account name


Dardex

Recommended Posts

Posted

Hello!

How can I block people who use color codes on their name when they want to register on server?

function RegisterHandler ( player, username, password) 
        local acc = addAccount(username,password) 
        if acc then 
                logIn(player,acc,password) 
                outputChatBox("You've been successfully registred!",player,0,125,0) 
                triggerClientEvent ( "CloseShit", getRootElement()) 
        else 
                outputChatBox("Hint:Do not use name colorcodes",player,125,0,0) 
                outputChatBox("Username is already taken.",player,125,0,0) 
        end 
end 
addEvent( "RegisterSubmit", true ) 
addEventHandler( "RegisterSubmit", getRootElement(), RegisterHandler ) 

this is registration function

Posted
if username:find ( "#%x%x%x%x%x%x" ) then    
    outputChatBox ( "You can't use HEX codes in the account name.", player, 255, 0, 0 ) 
    return 
end 

Posted

You can use this to check if a name has color codes:

if (string.find(name, '#%x%x%x%x%x%x')) then 

To remove color codes:

string.gsub(name, '#%x%x%x%x%x%x', '') 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...