Browse docs

Duty

Reference for Duty in sky_jobs_base.

All server exports

Duty

These exports allow external resources (e.g. admin menus, multijob scripts) to read and change a player's duty state.

setPlayerDuty(playerId, onDuty)

  • Purpose: Sets a player's duty state externally. Runs the full duty pipeline: on/off-duty job switch, duty event for all job scripts, and salary work-time session handling — exactly as if the player toggled duty themselves.
  • Arguments:
    • playerId (number) — the server ID of the player. Required.
    • onDuty (boolean) — true to set on duty, false to set off duty.
  • Returns: boolean — true when the resulting duty state matches the request, false when the player is invalid or their job cannot go on duty.
-- Force a player off duty (e.g. from an admin menu)
local ok = exports["sky_jobs_base"]:setPlayerDuty(playerId, false)

if not ok then
    print("Player is not on a duty-capable job")
end

isPlayerOnDuty(playerId)

  • Purpose: Checks whether a player is currently on duty.
  • Arguments:
    • playerId (number) — the server ID of the player.
  • Returns: boolean — true if on duty.
local onDuty = exports["sky_jobs_base"]:isPlayerOnDuty(playerId)

getOnDutyPlayers(jobName)

  • Purpose: Returns all currently on-duty players of a job.
  • Arguments:
    • jobName (string) — the job name. Required.
  • Returns: number[] — array of server IDs.
local medics = exports["sky_jobs_base"]:getOnDutyPlayers("ambulance")
print(("%d medics on duty"):format(#medics))