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 
) 

Developer @ MYVAL

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

I don't really understand what do you mean, since you can't use spaces on your nick.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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