Server Exports

Called from another resource’s server-side script.


Sync & Registry

GetPlayerJobs

Returns all tracked jobs for an online player.

ParameterTypeDescription
sourcenumberServer-side player source ID.

Returns: table array — job name, grade, duty state, and worked-hour totals per entry.

local jobs = exports['zephyr_multijob']:GetPlayerJobs(source)

SyncPlayerJobs

Re-syncs an online player’s QBox job groups into the multijob table and state cache. Useful after an admin-level job change made outside this resource.

exports['zephyr_multijob']:SyncPlayerJobs(source)

ForceRefreshJobRegistry

Forces the internal job registry to rebuild from the upstream job source. Call this after programmatically creating or deleting a job.

exports['zephyr_multijob']:ForceRefreshJobRegistry()

Job Membership

AddPlayerJob

Adds a job to a player — works for both online and offline players. Writes through to QBox and the multijob table.

ParameterTypeDescription
citizenidstringPlayer’s citizen ID.
jobNamestringJob to assign. Must exist in the QBox registry.
gradenumberGrade to assign.

Returns: boolean, string?true on success; false + error message on failure.

local ok, err = exports['zephyr_multijob']:AddPlayerJob('ABC123', 'police', 0)
if not ok then print('Failed: ' .. err) end

RemovePlayerJob

Removes a tracked job from a player, clears any active duty session, and keeps QBox in sync.

ParameterTypeDescription
citizenidstringPlayer’s citizen ID.
jobNamestringJob to remove.

Returns: boolean, string?

exports['zephyr_multijob']:RemovePlayerJob('ABC123', 'police')

PlayerHasJob

Returns true when the player has the named job in the multijob table.

local hasJob = exports['zephyr_multijob']:PlayerHasJob('ABC123', 'police')

GetPlayerJobCount

Returns the total number of jobs tracked for a player.

local count = exports['zephyr_multijob']:GetPlayerJobCount('ABC123')

GetJobMembers

Returns all players tracked under a job, optionally filtered to a minimum grade.

ParameterTypeDescription
jobNamestringJob to query.
minGradenumberOptional. Only return members at this grade or above.

Returns: table[] — each entry has citizenid and grade.

local members = exports['zephyr_multijob']:GetJobMembers('police')
local bosses  = exports['zephyr_multijob']:GetJobMembers('police', 3)

Duty

SetPlayerDuty

Explicitly sets a player’s duty state for a given job from a trusted server resource.

ParameterTypeDescription
sourcenumberServer-side player source ID.
isDutybooleantrue to put on duty, false to take off.
jobNamestringJob to update.
exports['zephyr_multijob']:SetPlayerDuty(source, true, 'police')
exports['zephyr_multijob']:SetPlayerDuty(source, false, 'police')

IsOnDuty

Fast in-memory duty check for an online player.

local onDuty = exports['zephyr_multijob']:IsOnDuty(source, 'police')

GetDutyStatus

Duty check by citizen ID.

local isDuty = exports['zephyr_multijob']:GetDutyStatus('ABC123', 'police')

ClockIn

Switches the player’s primary job if needed, marks them on duty, notifies them, and refreshes the UI in one call. Useful for zone-triggered or whitelist-triggered duty systems.

ParameterTypeDescription
sourcenumberServer-side player source ID.
jobNamestringJob to clock in to.

Returns: boolean, string

local ok, msg = exports['zephyr_multijob']:ClockIn(source, 'police')
if not ok then print('ClockIn failed: ' .. msg) end

ClockOut

Clocks a player out of a specific job, or all active duty jobs when jobName is omitted.

ParameterTypeDescription
sourcenumberServer-side player source ID.
jobNamestringOptional. Omit to clock out of all active jobs.

Returns: boolean, string

exports['zephyr_multijob']:ClockOut(source, 'police')  -- single job
exports['zephyr_multijob']:ClockOut(source)             -- all active jobs