OnAccountNameChange
Parameters
account theAccount, string previousName, string newName
- theAccount: The account being renamed.
- previousName: The account's current name.
- newName: The proposed new account name.
Source
The source of this event is the root element.
Canceling
If this event is canceled, the account name will not change and setAccountName will return false.
Example
This example prevents accounts from being renamed to names starting with "admin", regardless of capitalization.
addEventHandler("onAccountNameChange", root, function(theAccount, previousName, newName)
if newName:lower():sub(1, 5) == "admin" then
cancelEvent()
outputServerLog("Blocked account rename from " .. previousName .. " to " .. newName)
end
end)
Note
The event runs before the name is changed, so getAccountName still returns the previous name inside the handler.
See Also
Server events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled