Health Insurance

Configure insurance providers, billing cadence, and coverage expiration for Sky Ambulancejob.

How the Insurance System Works

Insurance is stored per player in sky_ambulance_insurance and tied to a provider defined in Config.HealthInsurance. Each provider defines the premium price and the patient co-pay percentage. When a medic issues a bill, the system checks the patient's coverage and notifies the medic with the insured status and co-pay.

Two billing modes are supported:

  • Recurring premium: the player is charged automatically on an interval (default every 60 minutes).
  • One-time premium with expiration: the player pays once and coverage expires after the configured number of days.

Core Configuration

All settings live in Config.HealthInsurance inside config/config.lua.

config.lua
Config.HealthInsurance = {
    enabled = true,
    command = "insurance",
    account = "bank",
    intervalMinutes = 60,
    chargeOnSelect = true,
    removeOnFailedCharge = true,
    expiration = {
        enabled = false,
        durationDays = 30
    },
    providers = {
        {
            id = "basic_care",
            label = "Basic Care",
            description = "Affordable coverage with higher patient participation.",
            price = 750,
            copayPercent = 50
        }
    }
}
  • enabled: master toggle for the entire system.
  • command: chat command used to open the insurance UI.
  • account: account to charge premiums (bank by default).
  • intervalMinutes: recurring premium interval (ignored when expiration is enabled).
  • chargeOnSelect: charge the premium immediately when a player selects a plan.
  • removeOnFailedCharge: cancel coverage if an automatic charge fails.
  • expiration.enabled: switch to one-time billing. Automatic charges stop.
  • expiration.durationDays: coverage length in days (7, 14, 30, etc.).
  • providers: list of available plans. Add more by duplicating entries.

Provider Fields

  • id: unique identifier used in the database.
  • label: displayed in the UI.
  • description: optional UI description.
  • price: premium amount.
  • copayPercent: percentage the patient still pays when billed.

Insurance Terminal Location (Optional)

You can add a world interaction (NPC/marker) to open the insurance UI.

  1. Use the hospital creator and add the Insurance terminal marker.
  2. The interaction uses the insurance_terminal interaction config in config/config.lua.
config.lua
Config.Interactions.insurance_terminal = {
    marker = { enabled = true, type = 1, offset = vector3(0.0, 0.0, 0.0) },
    blip = { enabled = false, name = "Insurance", sprite = 408, color = 2 },
    npc = { enabled = true, pedHash = "a_f_y_business_01", heading = 0.0 }
}

Database Fields

import.sql creates the insurance table:

CREATE TABLE IF NOT EXISTS `sky_ambulance_insurance` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `identifier` VARCHAR(64) NOT NULL,
  `provider_id` VARCHAR(64) NOT NULL,
  `next_charge` BIGINT NOT NULL DEFAULT 0,
  `last_charge` BIGINT NULL DEFAULT NULL,
  `expires_at` BIGINT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_identifier` (`identifier`)
);
  • next_charge / last_charge: used for recurring billing.
  • expires_at: used when expiration mode is enabled.

For existing installs:

ALTER TABLE sky_ambulance_insurance
ADD COLUMN expires_at BIGINT NOT NULL DEFAULT 0;

Billing Behavior

When a medic issues a bill:

  • The system checks whether the target is insured.
  • The medic receives a notification with the provider name and the patient co-pay percentage.
  • The UI shows the coverage status and the estimated patient charge.

If expiration is enabled, the UI shows a one-time payment message instead of an interval.