getAccountsByData | Multi Theft Auto: Wiki Skip to content

getAccountsByData

Client-side
Server-side
Shared

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

OOP Syntax Help! I don't understand this!

  • Method: Account.getAllByData(...)

Syntax

table|false getAccountsByData ( string dataName, string value )
Required Arguments
  • dataName: The name of the data.
  • value: The value the dataName should have.

Returns

  • table|false: accounts table

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

Code Examples

server

This example displays in the chat how many players are working in the police in a sample RPG gamemode after typing the command policecount.

addCommandHandler('policecount', function(player, cmd)
local accounts = getAccountsByData('rpg.job', 'police-officer')
outputChatBox('There are '..#accounts..' police officers working in the police', player)
end)