OnClientPlayerChangeNick: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Undo revision 22274 by Awwu (Talk))
(Undo revision 22275 by Sebassje (Talk) Does not compute. Also the example doesn't work.)
Line 15: Line 15:


==Example==  
==Example==  
This disallows changing a nick.
This example snippet sends a lame message every time player changes his nick.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler("onClientPlayerChangeNick", getLocalPlayer(),
addEventHandler ( "onClientPlayerChangeNick", getLocalPlayer(),
  function(oldNick, newNick)
    function ( oldNick, newNick )
    cancelEvent()
        outputChatBox ( "Hi " .. oldNick .. "! Oh... You're not " .. oldNick .. " anymore, are you?", 0, 255, 0 )
    outputChatBox("You can't change your nick!", 255, 0, 0)
        outputChatBox ( "I like your new name " .. newNick .. "!", 0, 255, 0 )
  end
    end
)
)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 19:50, 12 January 2010

This event is triggered when a player changes his nickname.

Parameters

string oldNick, string newNick
  • oldNick: the nickname the player had before.
  • newNick: the new nickname of the player.

Source

The source of this event is the player that changed his nick

Example

This example snippet sends a lame message every time player changes his nick.

addEventHandler ( "onClientPlayerChangeNick", getLocalPlayer(),
    function ( oldNick, newNick )
        outputChatBox ( "Hi " .. oldNick .. "! Oh... You're not " .. oldNick .. " anymore, are you?", 0, 255, 0 )
        outputChatBox ( "I like your new name " .. newNick .. "!", 0, 255, 0 )
    end
)

See Also

Client player events


Client event functions