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!

Syntax

table|false getAccountsByData ( ​string dataName, ​string value )
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.

  • table|false: accounts table

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)