Jump to content

Name blocker


Recommended Posts

Posted

how to make it block hex code names in game so that it automatically changes their name back to what it was when they try to change it to a hex color name.

Posted
addEventHandler( "onPlayerJoin", root, 
     function() 
         setPlayerName((getPlayerName( source )):gsub( "#%x%x%x%x%x%x", "" )) 
     end 
) 
  
addEventHandler( "onPlayerChangeNick", root, 
     function(old, name) 
        setPlayerName((name):gsub( "#%x%x%x%x%x%x", "" )) 
     end 
) 

Posted
addEventHandler( "onPlayerChangeNick", root, 
     function(old, name) 
        setPlayerName((name):gsub( "#%x%x%x%x%x%x", "" )) 
     end 
) 

Instead of that, you can just cancel the event if it has HEX codes in it.

Posted

thanks but when i try to use it to make sure it works it dosent then i make my name without a space with the hex code it lets the hex code work

Posted

Try this one:

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        local name = getPlayerName ( source ) 
        if name:find ( "#%x%x%x%x%x%x" ) then 
            setPlayerName ( source, name:gsub ( "#%x%x%x%x%x%x", "" ) ) 
        end 
    end 
) 
  
addEventHandler ( "onPlayerChangeNick", root, 
    function ( _, new ) 
        if new:find ( "#%x%x%x%x%x%x" ) then 
            cancelEvent ( ) 
        end 
    end 
) 

P.S: Is a server side script.

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...