ZH-CN/GetAccountsByData: 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|11747| This function returns a table containing all accounts with specified dataName and value (set with set...")
 
No edit summary
Line 2: Line 2:
{{Server function}}
{{Server function}}
{{New feature/item|3.0160|1.5.5|11747|
{{New feature/item|3.0160|1.5.5|11747|
This function returns a [[table]] containing all accounts with specified dataName and value (set with setAccountData).
此函数返回一个[[]],其中包含具有指定dataName和value的所有帐户(使用setAccountData设置).
}}
}}


==Syntax==  
==语法==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table getAccountsByData ( string dataName, string value )
table getAccountsByData ( string dataName, string value )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP|This function is a static function underneath the Account class.|Account.getAllByData||}}
{{OOP_ZH-CN|This function is a static function underneath the Account class.|Account.getAllByData||}}
===Required Arguments===  
===Required Arguments===  
*'''dataName:''' The name of the data
*'''dataName:''' 数据的名称
*'''value:''' The value the dataName should have
*'''value:''' The value the dataName should have


Line 17: Line 17:
Returns ''[[table]]'' containing the accounts associated with specified value at dataName. Returns ''false'' if invalid arguments were specified.
Returns ''[[table]]'' containing the accounts associated with specified value at dataName. Returns ''false'' if invalid arguments were specified.


==Example==  
==示例==  
Useless example to show how it works.
用一个无用的例子来说明它是如何工作的.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("accountsbydata", function (player)
addCommandHandler("accountsbydata", function (player)

Revision as of 08:55, 4 February 2021

此函数返回一个,其中包含具有指定dataName和value的所有帐户(使用setAccountData设置).

语法

table getAccountsByData ( string dataName, string value )

OOP 语法 什么是OOP?

提示: This function is a static function underneath the Account class.
方法: Account.getAllByData(...)

Required Arguments

  • dataName: 数据的名称
  • value: The value the dataName should have

Returns

Returns table containing the accounts associated with specified value at dataName. Returns false if invalid arguments were specified.

示例

用一个无用的例子来说明它是如何工作的.

addCommandHandler("accountsbydata", function (player)
   local account = getPlayerAccount(player)
   setAccountData(account, "test", "hello")
   local accounts = getAccountsByData("test", "hello")
   outputChatBox(getAccountName(accounts[1]), player)                
end)

See Also