OnPlayerChangeNick: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Added example) |
||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function nickChangeHandler(oldNick, newNick) | |||
-- check if there's account with newNick as username | |||
if getAccount(newNick) then | |||
local thePlayer = getPlayerFromNick(newNick) | |||
outputChatBox("Sorry, there already exists an account with your new nickname as username.", thePlayer, 0, 255, 0) | |||
outputChatBox("Please choose another one.", thePlayer, 0, 255, 0) | |||
-- cancel the event to prevent the nick from being changed | |||
cancelEvent() | |||
end | |||
end | |||
-- add an event handler | |||
addEventHandler("onPlayerChangeNick", getRootElement(), nickChangeHandler) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Player events}} | {{See also/Server event|Player events}} |
Revision as of 07:49, 7 August 2009
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
function nickChangeHandler(oldNick, newNick) -- check if there's account with newNick as username if getAccount(newNick) then local thePlayer = getPlayerFromNick(newNick) outputChatBox("Sorry, there already exists an account with your new nickname as username.", thePlayer, 0, 255, 0) outputChatBox("Please choose another one.", thePlayer, 0, 255, 0) -- cancel the event to prevent the nick from being changed cancelEvent() end end -- add an event handler addEventHandler("onPlayerChangeNick", getRootElement(), nickChangeHandler)
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled