Server Exports
Called from another resource’s server-side script.
Sync & Registry
GetPlayerJobs
Returns all tracked jobs for an online player.
| Parameter | Type | Description |
|---|---|---|
source | number | Server-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.
| Parameter | Type | Description |
|---|---|---|
citizenid | string | Player’s citizen ID. |
jobName | string | Job to assign. Must exist in the QBox registry. |
grade | number | Grade 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) endRemovePlayerJob
Removes a tracked job from a player, clears any active duty session, and keeps QBox in sync.
| Parameter | Type | Description |
|---|---|---|
citizenid | string | Player’s citizen ID. |
jobName | string | Job 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.
| Parameter | Type | Description |
|---|---|---|
jobName | string | Job to query. |
minGrade | number | Optional. 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.
| Parameter | Type | Description |
|---|---|---|
source | number | Server-side player source ID. |
isDuty | boolean | true to put on duty, false to take off. |
jobName | string | Job 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.
| Parameter | Type | Description |
|---|---|---|
source | number | Server-side player source ID. |
jobName | string | Job to clock in to. |
Returns: boolean, string
local ok, msg = exports['zephyr_multijob']:ClockIn(source, 'police')
if not ok then print('ClockIn failed: ' .. msg) endClockOut
Clocks a player out of a specific job, or all active duty jobs when jobName is omitted.
| Parameter | Type | Description |
|---|---|---|
source | number | Server-side player source ID. |
jobName | string | Optional. 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