Browse docs

Server Exports

Server-side exports provided by sky_jobs_base for dispatch, tablet app registration, and more.

Dispatch

createDispatch(title, message, coords, jobs, meta)

  • Purpose: Creates a dispatch entry and broadcasts it to all on-duty members of the target jobs.
  • Arguments:
    • title (string) — dispatch title. Required.
    • message (string) — dispatch description.
    • coords (vector3 | table) — location {x, y, z}. Required.
    • jobs (string | string[]) — job name or array of job names.
    • meta (table?) — optional metadata:
      • source (number?) — source player ID.
      • sourceId (string?) — additional source identifier.
      • category (string?) — dispatch category.
  • Returns: table | nil — the dispatch entry on success, nil on validation failure.
local dispatch = exports["sky_jobs_base"]:createDispatch(
    "Bank Robbery",
    "Silent alarm triggered at Pacific Standard",
    vector3(235.0, 216.0, 106.0),
    { "police" },
    { category = "robbery", source = source }
)

if dispatch then
    print("Dispatch created:", dispatch.id)
end

Dispatch Entry Structure

FieldTypeDescription
idstringUnique dispatch identifier
titlestringDispatch title
messagestringDispatch description
coordstableLocation {x, y, z}
jobstableTarget job names
statusstring"active" on creation
createdAtnumberTimestamp

HasDispatch(sourceKey, sourceId)

  • Purpose: Checks if an active dispatch exists for the given source.
  • Arguments:
    • sourceKey (string) — source identifier key.
    • sourceId (string) — source ID value.
  • Returns: booleantrue if a non-done dispatch exists.
local exists = exports["sky_jobs_base"]:HasDispatch("player", "license:abc123")

if exists then
    print("Active dispatch already exists")
end

takeServerImage(rawDataUrl, cameraMetadata)

  • Purpose: Uploads a base64 image to the configured image provider.
  • Arguments:
    • rawDataUrl (string) — base64-encoded image data URL.
    • cameraMetadata (table) — metadata about the camera/capture context.
  • Returns:
    • booleantrue on success, false on failure.
    • table | string — on success: { data = { url, id, image_id } }. On failure: error message.
local ok, result = exports["sky_jobs_base"]:takeServerImage(imageData, {
    type = "bodycam",
    timestamp = os.time()
})

if ok then
    print("Uploaded:", result.data.url)
end

Creator

openCreatorByJob(source, jobKey)

  • Purpose: Opens the registered station creator for a player by job key after validating the creator permission.
  • Arguments:
    • source (number) - server ID of the player who should receive the creator UI.
    • jobKey (string) - registered job key.
  • Returns:
    • boolean - true on success.
    • string? - failure reason such as "creator_not_found" or "no_permission".
local ok, reason = exports["sky_jobs_base"]:openCreatorByJob(source, "mechanic")

openCreatorByJobWithoutPermission(source, jobKey)

  • Purpose: Opens the registered station creator for a player by job key without running the creator permission check. Use only from trusted server-side integrations that already authorized the player.
  • Arguments:
    • source (number) - server ID of the player who should receive the creator UI.
    • jobKey (string) - registered job key.
  • Returns:
    • boolean - true on success.
    • string? - failure reason such as "creator_not_found" or "invalid_source".
local ok, reason = exports["sky_jobs_base"]:openCreatorByJobWithoutPermission(source, "mechanic")

Storage

AddStorageItem(stationId, jobName, grade, name, amount, metadata)

  • Purpose: Adds one item stack directly to a station storage. The export validates basic input and storage capacity before inserting.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • name (string) - item name.
    • amount (number) - positive item count.
    • metadata (table?) - optional item metadata.
  • Returns: boolean - true when the item was added.
local ok = exports["sky_jobs_base"]:AddStorageItem(
    "station_1",
    "mechanic",
    2,
    "repair_crate",
    1,
    { quality = 100 }
)

AddStorageItems(stationId, jobName, grade, items)

  • Purpose: Adds multiple item stacks directly to a station storage in one call. The export validates all items and checks total capacity before inserting.
  • Arguments:
    • stationId (string | number) - target station ID.
    • jobName (string) - job name used for storage restrictions.
    • grade (number?) - job grade context.
    • items (table[]) - array of items with name, amount or quantity, and optional metadata.
  • Returns: boolean - true when all valid items were added.
local ok = exports["sky_jobs_base"]:AddStorageItems("station_1", "mechanic", 2, {
    { name = "repair_crate", amount = 1, metadata = { quality = 100 } },
    { name = "cleaning_kit", quantity = 2 }
})

External Garage Integration

These exports allow third-party garage systems to register and unregister vehicles so the trunk inventory and prop system works for externally-spawned job vehicles.

registerExternalVehicle(plate, jobName, model, netId, ownerSource, trunkCapacity)

  • Purpose: Registers an externally-spawned vehicle in the sky_jobs_base vehicle tracking system. This enables trunk inventory, prop placement, and all trunk-related server callbacks for the vehicle.
  • Arguments:
    • plate (string) — the vehicle license plate. Required.
    • jobName (string) — the job this vehicle belongs to (e.g. "ambulance", "police"). Required.
    • model (string?) — vehicle model name (e.g. "ambulance"). Defaults to "unknown".
    • netId (number?) — network ID of the spawned vehicle entity.
    • ownerSource (number?) — server ID of the player who spawned the vehicle.
    • trunkCapacity (number?) — trunk weight capacity. Defaults to 50.
  • Returns: booleantrue on success, false if plate or jobName is missing.
-- After spawning the vehicle on the server:
local plate = GetVehicleNumberPlateText(vehicle)
local netId = NetworkGetNetworkIdFromEntity(vehicle)

exports["sky_jobs_base"]:registerExternalVehicle(
    plate,
    "ambulance",
    "ambulance",
    netId,
    source,
    80
)
External vehicles are not stored in the database. They only exist in memory and will be cleaned up on resource restart. Your garage system is responsible for its own persistence.

unregisterExternalVehicle(plate)

  • Purpose: Removes an externally-registered vehicle from the tracking system. Call this when the vehicle is despawned or parked by the external garage.
  • Arguments:
    • plate (string) — the vehicle license plate. Required.
  • Returns: booleantrue on success, false if plate is invalid.
exports["sky_jobs_base"]:unregisterExternalVehicle(plate)

Full Usage Example

-- When spawning the vehicle
RegisterNetEvent("mygarage:vehicleSpawned", function(plate, model, netId)
    exports["sky_jobs_base"]:registerExternalVehicle(
        plate, "ambulance", model, netId, source, 80
    )
end)

-- When despawning / parking the vehicle
RegisterNetEvent("mygarage:vehicleDespawned", function(plate)
    exports["sky_jobs_base"]:unregisterExternalVehicle(plate)
end)

Salary

These exports allow external resources (e.g. AFK scripts) to temporarily pause and resume salary payouts for a player, preventing paycheck farming.

pausePlayerSalary(playerId)

  • Purpose: Pauses salary payouts for the given player. While paused, the player will not receive any automatic salary payments.
  • Arguments:
    • playerId (number) — the server ID of the player. Required.
  • Returns: booleantrue on success, false if the player ID is invalid.
exports["sky_jobs_base"]:pausePlayerSalary(playerId)

resumePlayerSalary(playerId)

  • Purpose: Resumes salary payouts for the given player after they were paused.
  • Arguments:
    • playerId (number) — the server ID of the player. Required.
  • Returns: booleantrue on success, false if the player ID is invalid.
exports["sky_jobs_base"]:resumePlayerSalary(playerId)

isPlayerSalaryPaused(playerId)

  • Purpose: Checks whether salary payouts are currently paused for the given player.
  • Arguments:
    • playerId (number) — the server ID of the player.
  • Returns: booleantrue if paused, false otherwise.
local paused = exports["sky_jobs_base"]:isPlayerSalaryPaused(playerId)

getGradeSalary(jobName, grade)

  • Purpose: Reads the salary configuration of a job grade as configured in the boss menu.
  • Arguments:
    • jobName (string) — the job name. Required.
    • grade (number) — the job grade. Required.
  • Returns:
    • number — salary amount per interval (0 if none configured).
    • number — payout interval in minutes.
local amount, intervalMinutes = exports["sky_jobs_base"]:getGradeSalary("ambulance", 3)
print(("Grade 3 earns $%d every %d minutes"):format(amount, intervalMinutes))

Usage Example

-- When a player goes AFK
AddEventHandler("sky_afk:playerAFK", function(playerId)
    exports["sky_jobs_base"]:pausePlayerSalary(playerId)
end)

-- When a player returns from AFK
AddEventHandler("sky_afk:playerReturned", function(playerId)
    exports["sky_jobs_base"]:resumePlayerSalary(playerId)
end)
The pause state is stored in memory and automatically cleared when the player disconnects. No database changes are needed.

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: booleantrue 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: booleantrue 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))

Players & Members

These exports let external resources (admin menus, whitelist systems, other job scripts) manage job members without going through the boss menu.

getPlayerJobInfo(playerId)

  • Purpose: Returns the cached job state of an online player in one call.
  • Arguments:
    • playerId (number) — the server ID of the player. Required.
  • Returns: table | nil{ job, grade, gradeLabel, onDuty }, or nil if the player is not loaded.
local info = exports["sky_jobs_base"]:getPlayerJobInfo(playerId)

if info then
    print(("%s — grade %d (%s), on duty: %s"):format(info.job, info.grade, info.gradeLabel, tostring(info.onDuty)))
end

setJobMember(jobName, playerOrIdentifier, grade)

  • Purpose: Hires a player into a job or changes the grade of an existing member. Works for online players (server ID) and offline players (identifier). Updates the framework job, the player cache, and notifies open boss menus.
  • Arguments:
    • jobName (string) — the job name. Required.
    • playerOrIdentifier (number | string) — server ID or framework identifier. Required.
    • grade (number?) — target grade. Defaults to the job's lowest grade (hire).
  • Returns:
    • booleantrue on success.
    • string? — error message on failure (e.g. "Invalid grade").
-- Hire an online player at the default grade
local ok, err = exports["sky_jobs_base"]:setJobMember("ambulance", playerId)

-- Promote an offline player to grade 2
local ok, err = exports["sky_jobs_base"]:setJobMember("ambulance", "license:abc123", 2)

removeJobMember(jobName, playerOrIdentifier)

  • Purpose: Fires a member from a job. Sets the player to unemployed, ends their duty, and removes their member stats. Works for online and offline players.
  • Arguments:
    • jobName (string) — the job name. Required.
    • playerOrIdentifier (number | string) — server ID or framework identifier. Required.
  • Returns:
    • booleantrue on success.
    • string? — error message on failure.
local ok, err = exports["sky_jobs_base"]:removeJobMember("ambulance", "license:abc123")

getJobMembers(jobName)

  • Purpose: Returns all members of a job (online and offline) with their boss-menu stats.
  • Arguments:
    • jobName (string) — the job name. Required.
  • Returns: table[] — array of member entries.

Member Entry Structure

FieldTypeDescription
identifierstringFramework identifier
licensestringStored license identifier
namestringCharacter name
gradenumberJob grade
grade_labelstringGrade label
ondutybooleanCurrent duty state
last_online_timestampnumberUnix timestamp of last online
total_work_time_secondsnumberAccumulated on-duty time
actions_donenumberJob action counter
image_urlstring?Member image if set
local members = exports["sky_jobs_base"]:getJobMembers("ambulance")

for _, member in ipairs(members) do
    print(member.name, member.grade_label, member.onduty)
end

Society Money

Direct access to the job's shared account (the same account used by the boss menu finance tab).

getJobMoney(jobName)

  • Purpose: Returns the current shared account balance of a job.
  • Arguments:
    • jobName (string) — the job name. Required.
  • Returns: number — balance (0 on invalid job).
local balance = exports["sky_jobs_base"]:getJobMoney("ambulance")

addJobMoney(jobName, amount)

  • Purpose: Adds money to the job's shared account.
  • Arguments:
    • jobName (string) — the job name. Required.
    • amount (number) — positive amount. Required.
  • Returns: booleantrue on success.
exports["sky_jobs_base"]:addJobMoney("ambulance", 5000)

removeJobMoney(jobName, amount)

  • Purpose: Removes money from the job's shared account.
  • Arguments:
    • jobName (string) — the job name. Required.
    • amount (number) — positive amount. Required.
  • Returns: booleantrue on success, false when the account is invalid or the withdrawal fails.
if exports["sky_jobs_base"]:removeJobMoney("ambulance", 2500) then
    print("Invoice paid from society funds")
end

Permissions

hasJobPermission(playerId, permission, jobName)

  • Purpose: Checks whether a player's grade has a boss-menu permission. Useful for external resources that gate features behind management permissions.
  • Arguments:
    • playerId (number) — the server ID of the player. Required.
    • permission (number | string) — Permission enum value or key name (e.g. 3 or "MANAGE_MEMBERS"). Required.
    • jobName (string?) — when set, the check additionally requires the player to be on this job.
  • Returns: booleantrue if the grade has the permission (or the ALL permission).

Permission Keys

VIEW_LOGS, MANAGE_ROLES, MANAGE_MEMBERS, MANAGE_WAREHOUSE, MANAGE_MONEY, EDIT_OUTFITS, CREATE_OUTFITS, DELETE_OUTFITS, PURCHASE_SUPPLIES, PURCHASE_VEHICLES, GARAGE_VEHICLES, SELL_VEHICLES, TABLET_APPS, DOCUMENT_CLASSIFICATIONS, ALL

if exports["sky_jobs_base"]:hasJobPermission(playerId, "MANAGE_MONEY", "ambulance") then
    -- allow external payout action
end

Support

Need help? Our support team is always ready to assist

Join Discord