GetAccount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Edited language change)
 
(22 intermediate revisions by 15 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
This function returns an account for a specific user.  
This function returns an [[account]] for a specific user.  
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
account getAccount ( string username, [ string password ] )
account getAccount ( string username [, string password, bool caseSensitive = true ] )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[Account]]||}}
===Required Arguments===
===Required Arguments===
*'''username:''' The username of the account you want to retrieve
*'''username:''' The username of the account you want to retrieve
Line 13: Line 13:
{{OptionalArg}}
{{OptionalArg}}
*'''password:''' The password for the account. If this argument is not specified, you can get the account whatever password it is, otherwise the password must match the account's.
*'''password:''' The password for the account. If this argument is not specified, you can get the account whatever password it is, otherwise the password must match the account's.
{{New items|3.0157|1.5.6|
* '''caseSensitive''': Specifies whether to ignore the case when searching for an account.
|16257}}


===Returns===
===Returns===
An ''account'' value or ''false'' if an account matching the username specified (and password, if specified) could not be found.
Returns an [[account]] or ''false'' if an account matching the username specified (and password, if specified) could not be found.


==Example==
==Example==
[[Category:Needs Example]]
<section name="Server example 1" class="server" show="true">
This function checks if the account mentioned exists in the internal.db database file.
<syntaxhighlight lang="lua">
addCommandHandler("checkaccount",
function(player, cmd, account)
if hasObjectPermissionTo(player, "function.banPlayer" ) then -- if the player typing /checkaccount command has permission to banPlayer
if account and account ~= "" then -- if the account name was mentioned
if getAccount(account) then -- if the account exists
outputChatBox("Account "..account.." exists in the database!", player, 0, 255, 0)
else -- if the account doesn't exist
outputChatBox("Account "..account.." does not exist in database", player, 0, 255, 0)
end
else
outputChatBox("Syntax is /checkaccount [account name]", player, 255, 0, 0)
end
end
end
)
</syntaxhighlight></section>


==See Also==
==See Also==
{{Account functions}}
{{Account functions}}
[[en:getAccount]]
[[ar:getAccount]]
[[es:getAccount]]
[[pl:GetAccount]]
[[zh-cn:getAccount]]

Latest revision as of 15:02, 8 June 2022

This function returns an account for a specific user.

Syntax

account getAccount ( string username [, string password, bool caseSensitive = true ] )

OOP Syntax Help! I don't understand this!

Method: Account(...)


Required Arguments

  • username: The username of the account you want to retrieve

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • password: The password for the account. If this argument is not specified, you can get the account whatever password it is, otherwise the password must match the account's.
  • caseSensitive: Specifies whether to ignore the case when searching for an account.

Returns

Returns an account or false if an account matching the username specified (and password, if specified) could not be found.

Example

Click to collapse [-]
Server example 1

This function checks if the account mentioned exists in the internal.db database file.

addCommandHandler("checkaccount",
	function(player, cmd, account)
		if hasObjectPermissionTo(player, "function.banPlayer" ) then -- if the player typing /checkaccount command has permission to banPlayer
			if account and account ~= "" then -- if the account name was mentioned
				if getAccount(account) then -- if the account exists
					outputChatBox("Account "..account.." exists in the database!", player, 0, 255, 0)
				else -- if the account doesn't exist
					outputChatBox("Account "..account.." does not exist in database", player, 0, 255, 0)
				end
			else
			outputChatBox("Syntax is /checkaccount [account name]", player, 255, 0, 0)
			end
		end
	end
)

See Also