SetAccountPassword: Difference between revisions
Jump to navigation
Jump to search
m (li fix) |
m (Добавление языков) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
{{Server function}} | {{Server function}} | ||
This function sets the password of the specified [[account]]. | This function sets the password of the specified [[account]]. | ||
{{note| Don't forget to give admin rights to the resource, in which you are using setAccountPassword function or it won't work.}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setAccountPassword ( account theAccount, string password | bool setAccountPassword ( account theAccount, string password ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[account]]:setPassword|password|}} | {{OOP||[[account]]:setPassword|password|}} | ||
Line 11: | Line 12: | ||
*'''theAccount:''' the account whose password you want to set | *'''theAccount:''' the account whose password you want to set | ||
*'''password:''' the password | *'''password:''' the password | ||
{{Note|The password will always be encrypted with '''sha256''', other types are no longer supported. See [https://github.com/multitheftauto/mtasa-blue/wiki/CAccountPassword CAccountPassword] for more information.}} | |||
{{ | |||
===Returns=== | ===Returns=== | ||
Line 19: | Line 18: | ||
===Limits=== | ===Limits=== | ||
The following limits apply: | |||
* | * Minimum account password length is 1 character. | ||
* Maximum account password length is 30 characters. | * Maximum account password length is 30 characters. | ||
* Account password can not be equal to "*****" | * Account password can not be equal to "*****" | ||
Line 60: | Line 59: | ||
{{Account functions}} | {{Account functions}} | ||
[[en:setAccountPassword]] | |||
[[ru:setAccountPassword]] | |||
[[ar:setAccountPassword]] | [[ar:setAccountPassword]] | ||
[[es:setAccountPassword]] | [[es:setAccountPassword]] | ||
[[zh-cn:setAccountPassword]] |
Latest revision as of 15:48, 12 April 2021
This function sets the password of the specified account.
Syntax
bool setAccountPassword ( account theAccount, string password )
OOP Syntax Help! I don't understand this!
- Method: account:setPassword(...)
- Variable: .password
Required Arguments
- theAccount: the account whose password you want to set
- password: the password
Returns
Returns true if the password was set correctly, false otherwise.
Limits
The following limits apply:
- Minimum account password length is 1 character.
- Maximum account password length is 30 characters.
- Account password can not be equal to "*****"
Example
This example allows a user to change their password with a command.
function ChangePlayerPassword(player, command, oldpass, newpass) -- get the account the player is currently logged into local account = getPlayerAccount(player) if (account) then -- if its only a guest account, do not allow the password to be changed if (isGuestAccount(account)) then outputChatBox("You must be logged into an account to change your password.", player) -- end the function return end -- check that the old password is correct local password_check = getAccount(getAccountName(account), oldpass) if (password_check) then -- check the length of the new password if (string.len(newpass)>=5) then setAccountPassword(account,newpass) else outputChatBox("Your new password must be at least 5 characters long.", player) end else outputChatBox("Old password invalid.", player) end end end addCommandHandler("changepass", ChangePlayerPassword)
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