account
Client-side
Server-side
Shared
Element category: Account
The account class represents a player's server account. You can get the account object associated to any client using getPlayerAccount.
Accounts are unique to each client and can be used to store information that is persistent across map changes and user sessions. Clients that join without an account are given a temporary 'guest' account. This can store information like any other account, but isn't saved across sessions.
When a user logs in or out, the account object assigned to them will change. As such, you must not assume that the account attached to a client remains constant during their session.
PHP code to check password hashes from the MTA server database is
Here
This php function will return true if the password matches the hash from the accounts database.function passwordMatch( $plain, $hash ){ //-- Empty passwords never match if ( $plain == "" || $hash == "" ) return false;
if ( strlen($hash) == 64 + 32 + 1 ) { //-- SHA256 + type + salt $strSha256 = substr( $hash, 0, 64 ); $strType = substr( $hash, 64, 1 ); $strSalt = substr( $hash, 65, 32 );
//-- Password hash was generated from MD5, so do the same thing for the test if ( $strType == "1" ) $plain = strtoupper(md5($plain));
$strPasswordHashed = strtoupper(hash( "sha256", $strSalt . $plain )); return $strPasswordHashed == $strSha256; } else if ( strlen($hash) == 32 ) { //-- MD5 return strtoupper(md5($plain)) == $hash; } return false;}OOP Methods and Variables
- account:copyDataTo(...)
- account:getData(...)
- account:getID(...) Variable: .id
- account:getIP(...) Variable: .ip
- account:getName(...) Variable: .name
- account:getPlayer(...) Variable: .player
- account:getType(...)
- account:getSerial(...) Variable: .serial
- account:getAllData(...) Variable: .data
- account:isGuest(...) Variable: .guest
- account:remove(...)
- account:setData(...)
- account:setPassword(...) Variable: .password
- account:setSerial(...) Variable: .serial
- account:setName(...) Variable: .name
See Also
Account Functions
- addAccount
- copyAccountData
- getAccount
- getAccountByID
- getAccountData
- getAccountID
- getAccountIP
- getAccountName
- getAccountPlayer
- getAccounts
- getAccountsByData
- getAccountsByIP
- getAccountsBySerial
- getAccountSerial
- getAccountType
- getAllAccountData
- getPlayerAccount
- isGuestAccount
- logIn
- logOut
- removeAccount
- setAccountData
- setAccountName
- setAccountPassword
- setAccountSerial
Account Events
Account Elements
- account