Jump to content

help with change name


Blaawee

Recommended Posts

hello guys , i'm trying to change my name to arabic name in the chat

this is what i'v been do :

function changename( thePlayer, command, name ) 
    if ( name ) then 
    local newPlayerNick = " .. name .. " 
    local oldNick = getElementData( thePlayer, "ar.name" ) 
        if ( oldNick == false ) then 
            setElementData ( thePlayer, "ar.name", newPlayerNick ) 
            outputChatBox ("Your new nickname has been set to" .. getElementData( thePlayer, "ar.name", newPlayerNick ), thePlayer,0,255,0,true ) 
        else 
            outputChatBox ("Incorrect syntax, Correct: /name ", thePlayer,255,0,0,true ) 
        end 
    end 
end 
addCommandHandler( "name", changename ) 
  
function chat( msg, type ) 
    if type == 0 and getElementData( thePlayer, "ar.name", newPlayerNick ) ~= false then 
    cancelEvent() 
    outputChatBox("[ " .. newPlayerNick .. " ] : " .. msg, getRootElement(), 255, 255, 255, true) 
    end 
end 
addEventHandler("onPlayerChat", root, chat ) 

is there any way to make it

Link to comment
function changename( thePlayer, command, name ) 
    if ( not name ) then outputChatBox ("Incorrect syntax, Correct: /name ", thePlayer,255,0,0,true ) return end 
        local newPlayerNick = name 
        local oldNick = getElementData( thePlayer, "ar.name" ) 
        if ( oldNick == false ) then 
            setElementData ( thePlayer, "ar.name", newPlayerNick ) 
            outputChatBox ("Your new nickname has been set to: ".. newPlayerNick, thePlayer,0,255,0,true ) 
    end 
end 
addCommandHandler( "name", changename ) 
  
function chat( msg, type ) 
    if (type == 0 and getElementData( source, "ar.name" ) ~= false) then 
    cancelEvent() 
    outputChatBox("[ " .. tostring(getElementData( source, "ar.name" )) .. " ] : " .. msg, getRootElement(), 255, 255, 255, true) 
    end 
end 
addEventHandler("onPlayerChat", root, chat ) 

Link to comment

That's because you added a check to see if he already has a name.

function changename( thePlayer, command, name ) 
    if ( not name ) then outputChatBox ("Incorrect syntax, Correct: /name ", thePlayer,255,0,0,true ) return end 
    local newPlayerNick = name 
    setElementData ( thePlayer, "ar.name", newPlayerNick ) 
    outputChatBox ("Your new nickname has been set to: ".. newPlayerNick, thePlayer,0,255,0,true ) 
end 
addCommandHandler( "name", changename ) 
  
function chat( msg, type ) 
    if (type == 0 and getElementData( source, "ar.name" ) ~= false) then 
    cancelEvent() 
    outputChatBox("[ " .. tostring(getElementData( source, "ar.name" )) .. " ] : " .. msg, getRootElement(), 255, 255, 255, true) 
    end 
end 
addEventHandler("onPlayerChat", root, chat ) 

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