Difference between revisions of "GetAccountsByData"

From Multi Theft Auto: Wiki
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__NOTOC__  
 
__NOTOC__  
 
{{Server function}}
 
{{Server function}}
This function returns a [[table]] containing all accounts with specified dataName and value (setted with setAccountData)
+
{{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).
 +
}}
  
 
==Syntax==  
 
==Syntax==  
Line 16: Line 18:
  
 
==Example==  
 
==Example==  
 +
Useless example to show how it works.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Useless example to show how it works.
 
 
addCommandHandler("accountsbydata", function (player)
 
addCommandHandler("accountsbydata", function (player)
 
   local account = getPlayerAccount(player)
 
   local account = getPlayerAccount(player)

Latest revision as of 22:51, 1 July 2018

BETA: FROM VERSION 1.5.5 r11747 ONWARDS

This function returns a table containing all accounts with specified dataName and value (set with setAccountData).

Syntax

table getAccountsByData ( string dataName, string value )

OOP Syntax Help! I don't understand this!

Note: This function is a static function underneath the Account class.
Method: Account.getAllByData(...)

Required Arguments

  • dataName: The name of the data
  • 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.

Example

Useless example to show how it works.

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