ZH-CN/GetAccountByID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Обновление информации)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server function}}
{{Server function}}
{{New feature/item|3.0160|1.5.5|12217|
{{New feature/item|3.156|1.5.5|12217|
此函数返回具有特定ID的帐户.
此函数返回具有特定ID的帐户.
}}
}}


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
account getAccountByID ( int id )
account getAccountByID ( int id )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===必填参数===  
*'''id:''' The ID to get account from
*'''id:''' 要获取的账号的ID


===Returns===
===返回值===
Returns ''[[account]]'' associated with specified ID. Returns ''false'' if invalid arguments were specified or there is no account with this ID.
返回与指定ID关联的“[[账户]]”([[Account]])。如果指定的参数无效或没有具有此ID的帐户,则返回“false”.


==Example==  
==示例==  
This example adds command ''getAccount'' that outputs the account-name of the account with ID.
此示例添加命令“getAccount”,该命令输出此ID代表账户的用户名.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("getAccount",  
addCommandHandler("getAccount",  
Line 33: Line 33:
==See Also==
==See Also==
{{Account_functions}}
{{Account_functions}}
[[en:GetAccountByID]]
[[ru:GetAccountByID]]
[[zh-cn:GetAccountByID]]
[[zh-cn:GetAccountByID]]

Latest revision as of 17:14, 12 April 2021

ADDED/UPDATED IN VERSION 1.5.5 r12217:

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

语法

account getAccountByID ( int id )

必填参数

  • id: 要获取的账号的ID

返回值

返回与指定ID关联的“账户”(Account)。如果指定的参数无效或没有具有此ID的帐户,则返回“false”.

示例

此示例添加命令“getAccount”,该命令输出此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