# Minigames

> Reference for Minigames in ambulancejob.

[All client exports](/docs/jobs/ambulancejob/api/client-exports)

## Minigames

The ambulancejob minigames can be used standalone from any other resource. Each export opens the minigame UI and yields until the player completes or fails it.

### `StartMinigame(type, options?)`

- **Purpose**: Starts any minigame by type. This is the universal entry point for all standalone minigames.
- **Arguments**:

  - `type` (`string`): The minigame to start — see table below.
  - `options` (`table?`): Optional configuration.
  
    - `variant` (`string?`): For `bandage_wrap` only — `"arm"`, `"leg"`, `"head"`, or `"torso"` (default `"arm"`).
    - `messages` (`table?`): Override any display text in the minigame UI. Keys match the short locale keys of each component (e.g. `title`, `subtitle`, `hint`, `fail`, `success`). Any key not provided falls back to the default locale string.
- **Returns**:

  - `boolean`: `true` when the minigame started, `false` on error.
  - `boolean | string`: When started — `true` on success, `false` on fail. When not started — error reason (`"invalid_type"`, `"busy"`).

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        "bandage_wrap"
      </code>
    </td>
    
    <td>
      Trace a spiral path to wrap a wound. Accepts <code>
        variant
      </code>
      
       option.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "cpr"
      </code>
    </td>
    
    <td>
      Full CPR — hit compression beats at rhythm, then deliver rescue breaths.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "cpr_compressions"
      </code>
    </td>
    
    <td>
      Chest compressions only (no ventilation phase).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "cpr_ventilation"
      </code>
    </td>
    
    <td>
      Rescue breaths only (trace the airflow wave).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "bullet_extraction"
      </code>
    </td>
    
    <td>
      Drag a bullet upward through a canal without hitting the walls.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "saline_infusion"
      </code>
    </td>
    
    <td>
      Regulate IV drip flow by adjusting a clamp to the target rate.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "blood_transfusion"
      </code>
    </td>
    
    <td>
      Control blood flow rate within the target zone.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        "bag_valve_mask"
      </code>
    </td>
    
    <td>
      Trace an airflow wave to deliver breaths (3 breaths required).
    </td>
  </tr>
</tbody>
</table>

```lua
local started, result = exports["sky_ambulancejob"]:StartMinigame("cpr")
if started and result then
    print("CPR successful!")
end
```

#### Message overrides

Every minigame component resolves its display text through short keys. Pass a `messages` table to override any of them:

```lua
local started, success = exports["sky_ambulancejob"]:StartMinigame("bullet_extraction", {
    messages = {
        title    = "Remove the splinter",
        subtitle = "Carefully pull it out without touching the walls.",
        fail     = "Wall contact!",
        success  = "Removed!",
    }
})
```

Keys that are **not** provided in the table fall back to the configured locale. Below is the full key reference for each minigame type.

#### `bandage_wrap`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Note
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      <em>
        (per variant)
      </em>
    </td>
    
    <td>
      Overrides the variant-specific title
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        titles.arm
      </code>
    </td>
    
    <td>
      Apply arm gauze wrap
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        titles.leg
      </code>
    </td>
    
    <td>
      Apply leg gauze wrap
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        titles.head
      </code>
    </td>
    
    <td>
      Apply head gauze wrap
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        titles.torso
      </code>
    </td>
    
    <td>
      Stabilize torso gauze wrap
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subtitle
      </code>
    </td>
    
    <td>
      Follow the spiral path and stay close to the guide.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hint
      </code>
    </td>
    
    <td>
      Start at the highlighted point and wrap upward in a spiral.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fail
      </code>
    </td>
    
    <td>
      Too far away - try again!
    </td>
    
    <td>
      
    </td>
  </tr>
</tbody>
</table>

#### `cpr` / `cpr_compressions`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Note
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        compressAction
      </code>
    </td>
    
    <td>
      Press Space or click with the rhythm
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        missLabel
      </code>
    </td>
    
    <td>
      Misses {count}/{max}
    </td>
    
    <td>
      Supports <code>
        {count}
      </code>
      
      , <code>
        {max}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        cycleLabel
      </code>
    </td>
    
    <td>
      Cycle {count}/{total}
    </td>
    
    <td>
      Supports <code>
        {count}
      </code>
      
      , <code>
        {total}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        phaseCompressions
      </code>
    </td>
    
    <td>
      {count} compressions
    </td>
    
    <td>
      Supports <code>
        {count}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        phaseVentilation
      </code>
    </td>
    
    <td>
      Deliver {count} breaths
    </td>
    
    <td>
      Only in full <code>
        cpr
      </code>
      
       mode
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationStageTitle
      </code>
    </td>
    
    <td>
      Rescue breaths
    </td>
    
    <td>
      Only in full <code>
        cpr
      </code>
      
       mode
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationStageSubtitle
      </code>
    </td>
    
    <td>
      Trace the mask alignment to deliver airflow.
    </td>
    
    <td>
      Only in full <code>
        cpr
      </code>
      
       mode
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationProgress
      </code>
    </td>
    
    <td>
      Breaths {count}/{total}
    </td>
    
    <td>
      Only in full <code>
        cpr
      </code>
      
       mode
    </td>
  </tr>
</tbody>
</table>

#### `cpr_ventilation`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ventilationTitle
      </code>
    </td>
    
    <td>
      Deliver rescue breaths
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationSubtitle
      </code>
    </td>
    
    <td>
      Trace the airflow curve to deliver a breath.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationHint
      </code>
    </td>
    
    <td>
      Start at the highlighted marker and follow the wave.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ventilationFail
      </code>
    </td>
    
    <td>
      Breath lost - reset and try again.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failTimeout
      </code>
    </td>
    
    <td>
      Ventilation aborted - too slow.
    </td>
  </tr>
</tbody>
</table>

#### `bullet_extraction`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      Extract the bullet
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subtitle
      </code>
    </td>
    
    <td>
      Drag the bullet straight up without touching the canal walls.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hint
      </code>
    </td>
    
    <td>
      Stay centered between the glowing rails.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progress
      </code>
    </td>
    
    <td>
      Extraction progress
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        exit
      </code>
    </td>
    
    <td>
      Exit
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        fail
      </code>
    </td>
    
    <td>
      Wall contact! Try again.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        success
      </code>
    </td>
    
    <td>
      Bullet removed.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        bulletAlt
      </code>
    </td>
    
    <td>
      Deformed bullet
    </td>
  </tr>
</tbody>
</table>

#### `saline_infusion`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Note
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      Saline infusion
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subtitle
      </code>
    </td>
    
    <td>
      Regulate the drip and keep the flow steady.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rate
      </code>
    </td>
    
    <td>
      Drip rate
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progress
      </code>
    </td>
    
    <td>
      Infusion progress
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stop
      </code>
    </td>
    
    <td>
      Abort infusion
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        targetHint
      </code>
    </td>
    
    <td>
      Keep between {low}–{high} drops/min
    </td>
    
    <td>
      Supports <code>
        {low}
      </code>
      
      , <code>
        {high}
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        adjust
      </code>
    </td>
    
    <td>
      Adjust the clamp into the highlighted zone.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        success
      </code>
    </td>
    
    <td>
      Flow is stable.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failOver
      </code>
    </td>
    
    <td>
      Flow too high!
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failUnder
      </code>
    </td>
    
    <td>
      Line collapsed - reopen the clamp.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failTimeout
      </code>
    </td>
    
    <td>
      Infusion aborted - took too long.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progressHint
      </code>
    </td>
    
    <td>
      Keep steady… {value}%
    </td>
    
    <td>
      Supports <code>
        {value}
      </code>
    </td>
  </tr>
</tbody>
</table>

#### `blood_transfusion`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Note
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      Blood transfusion setup
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subtitle
      </code>
    </td>
    
    <td>
      Stabilise the transfusion flow.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rate
      </code>
    </td>
    
    <td>
      Flow rate
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progress
      </code>
    </td>
    
    <td>
      Infusion progress
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stop
      </code>
    </td>
    
    <td>
      Abort transfusion
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        adjust
      </code>
    </td>
    
    <td>
      Adjust the regulator into the highlighted zone.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        stageComplete
      </code>
    </td>
    
    <td>
      Flow stabilised.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failOver
      </code>
    </td>
    
    <td>
      Flow too strong! Slow down.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failUnder
      </code>
    </td>
    
    <td>
      Line collapsed! Raise the flow.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        failTimeout
      </code>
    </td>
    
    <td>
      Transfusion aborted - procedure took too long.
    </td>
    
    <td>
      
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progressHint
      </code>
    </td>
    
    <td>
      Hold steady… {value}%
    </td>
    
    <td>
      Supports <code>
        {value}
      </code>
    </td>
  </tr>
</tbody>
</table>

#### `bag_valve_mask`

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Default
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        title
      </code>
    </td>
    
    <td>
      Bag valve mask ventilation
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        subtitle
      </code>
    </td>
    
    <td>
      Trace the airflow curve to deliver a breath.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hint
      </code>
    </td>
    
    <td>
      Start at the highlighted marker and follow the wave.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        progress
      </code>
    </td>
    
    <td>
      Breaths {count}/{total}
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        successBreath
      </code>
    </td>
    
    <td>
      Breath delivered
    </td>
  </tr>
</tbody>
</table>

<callout color="info" icon="i-lucide-info">

`StartMinigame` is **yielding** — it blocks the current thread until the player finishes or cancels the minigame. Call it inside a `CreateThread` or `Citizen.CreateThread` to avoid blocking your main thread.

</callout>

### `IsMinigameActive()`

- **Purpose**: Checks if a standalone minigame is currently running.
- **Returns**: `boolean`

```lua
if exports["sky_ambulancejob"]:IsMinigameActive() then
    print("A minigame is in progress")
end
```

### `GetActiveMinigame()`

- **Purpose**: Returns the type of the currently active standalone minigame.
- **Returns**: `string | nil`

```lua
local active = exports["sky_ambulancejob"]:GetActiveMinigame()
```

### `CancelMinigame()`

- **Purpose**: Cancels the currently running standalone minigame. The minigame counts as failed.

```lua
exports["sky_ambulancejob"]:CancelMinigame()
```

### `GetAvailableMinigames()`

- **Purpose**: Returns a table of all minigame types with their enabled/disabled state from `Config.Minigames.enabled`.
- **Returns**: `table<string, boolean>`

```lua
local available = exports["sky_ambulancejob"]:GetAvailableMinigames()
for name, enabled in pairs(available) do
    print(name .. ": " .. tostring(enabled))
end
```

<br />

### Example: Using minigames in another resource

```lua
-- In your custom resource (client-side)
CreateThread(function()
    -- Example: require a CPR minigame before reviving
    local started, success = exports["sky_ambulancejob"]:StartMinigame("cpr")
    if started and success then
        TriggerServerEvent("myresource:revivePlayer")
    else
        TriggerEvent("chat:addMessage", {
            args = { "CPR failed — the patient could not be revived." }
        })
    end
end)
```

```lua
-- Example: bandage wrap as a skill check with custom text
RegisterCommand("applybandage", function()
    CreateThread(function()
        local started, success = exports["sky_ambulancejob"]:StartMinigame("bandage_wrap", {
            variant = "arm",
            messages = {
                title = "Apply field dressing",
                subtitle = "Wrap the wound carefully.",
            }
        })
        if started and success then
            print("Bandage applied successfully")
        end
    end)
end)
```

<br />
