Jump to content

color code


waleedrt

Recommended Posts

Here is a snippet of some old code from CSG. It checks for hex, and if a player's name is just hex (which some people do, I don't know why), it will assign them a random name.

-- Remove hex 
function removeHEX(oldNick, newNick) 
    local name = getPlayerName(source) 
    if newNick then 
        name = newNick 
    end 
    if name:find("#%x%x%x%x%x%x") then 
        local name = name:gsub("#%x%x%x%x%x%x","") 
        if name:len() > 0 then 
            setPlayerName(source, name) 
        else 
            setPlayerName(source, "Player"..tostring(math.random(10000,99990))) 
        end 
        if newNick then 
            cancelEvent() 
        end 
    end 
end 
addEventHandler("onPlayerJoin", root, removeHEX) 
addEventHandler("onPlayerChangeNick", root, removeHEX) 

Link to comment

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