setAccountName | Multi Theft Auto: Wiki Skip to content

setAccountName

Client-side
Server-side
Shared

Pair: getAccountName

This function sets the name of an account.

OOP Syntax Help! I don't understand this!

  • Method: account:setName(...)
  • Variable: .name

Syntax

bool setAccountName ( account theAccount, string name, [ bool allowCaseVariations = false ] )
Required Arguments
  • theAccount: The account you wish to change the name.
  • name: The new name.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • allowCaseVariations (default: false): Whether the username is case sensitive (if this is set to true, usernames "Bob" and "bob" will refer to different accounts).

Returns

  • bool: result

Returns a true if the account name was set, false if an invalid argument was specified.

Code Examples

server

Change the name of an account.

addCommandHandler("changeaccountname", function(player, _, oldname, newname)
if (not oldname or not newname) then
return
end
local account = getAccount(oldname)
if (not account) then
return
end
setAccountName(account, newname)
outputChatBox("Success!", player)
end)