Browse docs

Server Exports

Server-side exports provided by the Sky Ambulancejob resource.

Dispatch

Create a dispatch for the MDT Tablet.

exports["sky_jobs_base"]:createDispatch(
    "Medical Emergency", -- title
    "Caller reports an unconscious person requiring immediate medical assistance.", -- description
    GetEntityCoords(PlayerPedId()), -- coords (vector3)
    { "ambulance", "firefighter" } -- jobs
)

Exports

revive(playerId, context?)

  • Purpose: Revives the supplied player.
  • Arguments:
    • playerId (number|string): The server ID of the player that should be revived.
    • context (table?): Optional revive context.
      • reason (string?): Controls post-revive behaviour.
        • "command" — Admin/force revive. Skips the death timeout (combat lockout).
        • "txadmin_heal" — Same as "command".
        • "heal_command" — Same as "command".
        • nil / omitted — Normal revive. Death timeout applies as configured.
  • Returns: boolean (true when the revive was triggered, false for an invalid or offline target).
-- Normal revive
exports["sky_ambulancejob"]:revive(playerId)

-- Admin revive (skips death timeout)
exports["sky_ambulancejob"]:revive(playerId, { reason = "command" })

isDead(playerId)

  • Purpose: Reports whether the specified player is currently flagged as dead by the ambulance job logic.
  • Arguments:
    • playerId (number|string): The server ID of the player whose state should be checked.
  • Returns: boolean (true when the player is dead or downed, false otherwise).
exports["sky_ambulancejob"]:isDead(playerId)

getStretcherModels()

  • Purpose: Returns the list of vehicle models configured as stretcher vehicles.
  • Returns: table — array of model hashes used for stretcher transport.
local models = exports["sky_ambulancejob"]:getStretcherModels()

Insurance

Read and write access to the health-insurance system used by the ambulance billing flow. Read exports let other resources check coverage, calculate co-pays, and enumerate providers. Write exports let admin menus, hospital welcome flows, or custom integrations grant, remove, or extend coverage without charging the player (the in-game /insurance command remains the normal purchase flow).

isInsuranceEnabled()

  • Purpose: Reports whether the insurance subsystem is enabled in Config.HealthInsurance.
  • Returns: booleantrue when enabled.
if exports["sky_ambulancejob"]:isInsuranceEnabled() then
    -- insurance features are available
end

hasInsurance(playerId)

  • Purpose: Quick check whether a player currently has active insurance coverage.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: booleantrue when insured, false otherwise (also false when insurance is disabled).
local insured = exports["sky_ambulancejob"]:hasInsurance(playerId)

getCoverage(playerId)

  • Purpose: Returns a compact summary of the player's current coverage.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: table | nil:
    • providerId (string) — Provider ID (e.g. "standard_care").
    • label (string) — Display name (e.g. "Standard Care").
    • copayPercent (number) — Patient co-pay percentage.
    • price (number) — Configured base premium.
    • expiresAt (number) — Unix timestamp when coverage expires; 0 when no expiration.
local coverage = exports["sky_ambulancejob"]:getCoverage(playerId)
if coverage then
    print(coverage.label, coverage.copayPercent, coverage.expiresAt)
end

getProvider(playerId)

  • Purpose: Returns the full provider record (including description) assigned to the player.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: table | nil{ id, label, description, price, copayPercent }.
local provider = exports["sky_ambulancejob"]:getProvider(playerId)

getCopayPercent(playerId)

  • Purpose: Returns the percentage the player will pay on a medical bill.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: number — Co-pay percentage (100 when uninsured or insurance disabled).
local percent = exports["sky_ambulancejob"]:getCopayPercent(playerId)

getExpiresAt(playerId)

  • Purpose: Returns the Unix timestamp at which the player's coverage expires.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: number — Unix timestamp; 0 when coverage has no expiration or the player is uninsured.
local expiresAt = exports["sky_ambulancejob"]:getExpiresAt(playerId)

calculateCopay(playerId, billAmount)

  • Purpose: Calculates how much a patient would pay for a given bill amount, taking their active health insurance into account. If the player has no insurance or insurance is disabled, the full bill amount is returned.
  • Arguments:
    • playerId (number): The server ID of the player whose insurance should be checked.
    • billAmount (number): The original bill amount in dollars.
  • Returns: table with:
    • copayAmount (number) — The amount the patient pays after insurance.
    • originalAmount (number) — The original bill amount passed in.
    • hasInsurance (boolean) — Whether the player has active insurance.
    • provider (table?) — Insurance provider details (only when insured):
      • id (string) — Provider ID (e.g. "standard_care").
      • label (string) — Display name (e.g. "Standard Care").
      • copayPercent (number) — The percentage the patient pays (e.g. 30).
-- Example: Patient with "Standard Care" (30% copay) and a $900 bill
local result = exports["sky_ambulancejob"]:calculateCopay(playerId, 900)

print(result.copayAmount)   -- 270 (patient pays 30%)
print(result.originalAmount) -- 900
print(result.hasInsurance)   -- true
print(result.provider.label) -- "Standard Care"

-- Example: Patient without insurance
local result = exports["sky_ambulancejob"]:calculateCopay(playerId, 900)

print(result.copayAmount)   -- 900 (full amount)
print(result.hasInsurance)   -- false

calculateInsuranceCopay(playerId, billAmount)

  • Purpose: Alias for calculateCopay, kept for backward compatibility. Returns identical results.
local result = exports["sky_ambulancejob"]:calculateInsuranceCopay(playerId, 900)

getAllProviders()

  • Purpose: Returns every insurance provider configured in Config.HealthInsurance.providers, sorted alphabetically by label.
  • Returns: table — array of { id, label, description, price, copayPercent } entries (cloned, safe to mutate).
for _, provider in ipairs(exports["sky_ambulancejob"]:getAllProviders()) do
    print(provider.id, provider.label, provider.price)
end

getProviderById(providerId)

  • Purpose: Returns a single configured provider by its id.
  • Arguments:
    • providerId (string): The provider identifier (e.g. "basic_care").
  • Returns: table | nil.
local provider = exports["sky_ambulancejob"]:getProviderById("basic_care")

getInsuranceConfig()

  • Purpose: Returns a read-only snapshot of the high-level insurance configuration.
  • Returns: table:
    • enabled (boolean)
    • command (string) — Chat command used to open the UI.
    • account (string) — Account premiums are charged from.
    • expirationOptions (table) — Sorted array of valid durationDays values.
local cfg = exports["sky_ambulancejob"]:getInsuranceConfig()
print(cfg.command, cfg.account)
The following write exports do not charge the player. They are integration hooks intended for admin menus, hospital welcome flows, or custom scripts. Use the in-game /insurance command for the normal player-purchase flow.

setInsurance(playerId, providerId, durationDays?)

  • Purpose: Assigns or refreshes coverage for the player. When called with the same provider that the player already holds, the duration is appended to the existing expiration (mirrors the in-game purchase flow).
  • Arguments:
    • playerId (number): The server ID of the player.
    • providerId (string): One of the configured provider IDs.
    • durationDays (number?): Number of days the coverage lasts. Must be one of Config.HealthInsurance.expiration.availableDays. Defaults to the configured default duration when omitted.
  • Returns: boolean, string?true on success, otherwise false and one of:
    • "disabled" — insurance is disabled in config.
    • "invalid_provider" — unknown providerId.
    • "invalid_player" — player not online.
    • "invalid_identifier" — could not resolve identifier.
    • "invalid_duration" — duration not in availableDays.
local ok, err = exports["sky_ambulancejob"]:setInsurance(playerId, "basic_care", 7)
if not ok then
    print("setInsurance failed:", err)
end

removeInsurance(playerId)

  • Purpose: Removes the player's coverage and clears the cache.
  • Arguments:
    • playerId (number): The server ID of the player.
  • Returns: booleantrue when a coverage row was removed, false when the player had no coverage.
exports["sky_ambulancejob"]:removeInsurance(playerId)

extendInsurance(playerId, additionalDays)

  • Purpose: Extends an existing coverage's expiration by the given number of days. Base is the later of now and the current expiresAt.
  • Arguments:
    • playerId (number): The server ID of the player.
    • additionalDays (number): Days to add (must be > 0).
  • Returns: boolean, string?true on success, otherwise false and one of:
    • "disabled" — insurance is disabled in config.
    • "invalid_player" — player not online.
    • "invalid_duration"additionalDays is missing or non-positive.
    • "not_insured" — player has no active coverage.
local ok, err = exports["sky_ambulancejob"]:extendInsurance(playerId, 3)

Salary

Pause or resume salary payouts for ambulance employees. These exports are provided by sky_jobs_base and work for all job types.

pausePlayerSalary(playerId)

  • Purpose: Pauses salary payouts for the given player.
  • Arguments:
    • playerId (number) — the server ID of the player.
  • Returns: booleantrue on success.

resumePlayerSalary(playerId)

  • Purpose: Resumes salary payouts for the given player.
  • Arguments:
    • playerId (number) — the server ID of the player.
  • Returns: booleantrue on success.

isPlayerSalaryPaused(playerId)

  • Purpose: Checks whether salary payouts are currently paused.
  • Arguments:
    • playerId (number) — the server ID of the player.
  • Returns: booleantrue if paused.
-- Pause salary (e.g. when player is AFK)
exports["sky_jobs_base"]:pausePlayerSalary(playerId)

-- Resume salary (e.g. when player returns)
exports["sky_jobs_base"]:resumePlayerSalary(playerId)

-- Check if paused
local paused = exports["sky_jobs_base"]:isPlayerSalaryPaused(playerId)
See the Sky Jobs Base Server Exports for full documentation and usage examples.

Support

Need help? Our support team is always ready to assist

Join Discord