ZH-CN/GetAccountByID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server function}} {{New feature/item|3.0160|1.5.5|12217| This function returns the account with the specific ID. }} ==Syntax== <syntaxhighlight lang="lua"> acco...")
 
No edit summary
Line 2: Line 2:
{{Server function}}
{{Server function}}
{{New feature/item|3.0160|1.5.5|12217|
{{New feature/item|3.0160|1.5.5|12217|
This function returns the account with the specific ID.
此函数返回具有特定ID的帐户.
}}
}}



Revision as of 08:30, 4 February 2021

此函数返回具有特定ID的帐户.

Syntax

account getAccountByID ( int id )

Required Arguments

  • id: The ID to get account from

Returns

Returns account associated with specified ID. Returns false if invalid arguments were specified or there is no account with this ID.

Example

This example adds command getAccount that outputs the account-name of the account with ID.

addCommandHandler("getAccount", 
	function (player, cmd, id)
                id = tonumber(id)
		local account = getAccountByID(id)
                if account then
		   outputChatBox("The name of the account with that ID is: "..getAccountName(account), player)
                else 
                   outputChatBox("There is no account with this ID.", player)
                end
	end)

See Also