SetAccountName: Difference between revisions
Jump to navigation
Jump to search
(Added to MTA natively in https://buildinfo.mtasa.com/index.php?Revision=11747) |
No edit summary |
||
Line 1: | Line 1: | ||
{{ | {{Server function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function | This function sets the name of an [[account]]. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">bool setAccountName ( | <syntaxhighlight lang="lua"> | ||
bool setAccountName ( account theAccount, string name [, bool allowCaseVariations = false] ) | |||
</syntaxhighlight> | |||
{{OOP||[[account]]:setName||name}} | |||
===Required Arguments=== | |||
*'''theAccount:''' The account you wish to change the name. | |||
*'''name:''' The new name. | |||
=== | ===Optional Arguments=== | ||
* ''' | *'''allowCaseVariations:''' Whether the username is case sensitive (if this is set to true, usernames "Bob" and "bob" will refer to different accounts) | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if account was | Returns a ''true'' if the account name was set, ''false'' if an invalid argument was specified. | ||
== | ==Example== | ||
Change the name of an account. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addCommandHandler("changeaccountname", function(player, _, oldname, newname) | |||
if not oldname or not newname then | |||
return | |||
end | |||
local account = getAccountByName(oldname) | |||
if not account then | |||
return | |||
end | |||
setAccountName(account, newname) | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== | ==See Also== | ||
{{Account_functions}} |
Revision as of 22:26, 1 July 2018
This function sets the name of an account.
Syntax
bool setAccountName ( account theAccount, string name [, bool allowCaseVariations = false] )
OOP Syntax Help! I don't understand this!
Required Arguments
- theAccount: The account you wish to change the name.
- name: The new name.
Optional Arguments
- allowCaseVariations: Whether the username is case sensitive (if this is set to true, usernames "Bob" and "bob" will refer to different accounts)
Returns
Returns a true if the account name was set, false if an invalid argument was specified.
Example
Change the name of an account.
addCommandHandler("changeaccountname", function(player, _, oldname, newname) if not oldname or not newname then return end local account = getAccountByName(oldname) if not account then return end setAccountName(account, newname) end)
See Also
- addAccount
- copyAccountData
- getAccount
- getAccountData
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccounts
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountPassword
- getAccountByID
- getAccountID
- getAccountIP
- getAccountsByData
- getAccountsByIP
- setAccountName