OPX//77
CreatorsServer exports

GetPlayers

Last updated on

Lists the loaded characters, optionally by job, gang or duty.

local res = exports.opx_infinity:GetPlayers(filter)

Scope read · sync.

Parameters

  • filter?: table

    • job?: string — only characters whose primary job is this one
    • gang?: string — only characters whose primary gang is this one
    • onDuty?: boolean — only on duty (true) or off duty (false)
  • A roster row is never a balance or metadata: use GetPlayerData for one player.

  • Sorted by player id.

Returns

  • table[] — { source, citizenId, firstName, lastName, job, gang } per character

Errors

  • export.badArgument, error.unavailable
Example
local res = exports.opx_infinity:GetPlayers({ job = 'ncpd', onDuty = true })
local cops = res.ok and #res.value or 0
if cops < 2 then return print('not enough officers on duty for a heist') end

On this page

No Headings