setAccountPassword
Client-side
Server-side
Shared
This function sets the password of the specified account.
Don't forget to give admin rights to the resource, in which you are using setAccountPassword function or it won't work.
- Minimal account password length is 1 character.
- Account password can not be equal to
*****
. - Maximum account password length was 30 characters until version 1.5.4-11138. Currently there is no upper limit.
The password will always be encrypted with sha256, other types are no longer supported.
OOP Syntax Help! I don't understand this!
- Method: account:setPassword(...)
- Variable: .password
Syntax
bool setAccountPassword ( account theAccount, string password )
Required Arguments
- theAccount: The account whose password you want to set.
- password: The password.
Returns
- bool: result
Returns true if the password was set correctly, false otherwise.
Code Examples
server
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 endendaddCommandHandler("changepass", ChangePlayerPassword)
Changelog
See Also
Account Functions
- addAccount
- copyAccountData
- getAccountByID
- getAccount
- getAccountData
- getAccountID
- getAccountIP
- getAccountName
- getAccountPlayer
- getAccountSerial
- getAccountType
- getAccounts
- getAccountsByData
- getAccountsByIP
- getAccountsBySerial
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- removeAccount
- logOut
- setAccountData
- setAccountName
- setAccountPassword
- setAccountSerial