# Player State and Revive

> Death, revive, god-mode and player-state server exports.

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

## Exports

### `killPlayer(playerId, customReason?)`

Sends a kill request to the specified player's ambulance death flow. Use an optional custom reason for integrations such as overdose systems.

```lua [server.lua]
local sent = exports["sky_ambulancejob"]:killPlayer(playerId, "Overdose")

-- Keep the default forced-death reason:
local sentDefault = exports["sky_ambulancejob"]:killPlayer(playerId)
```

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

<tbody>
  <tr>
    <td>
      <code>
        playerId
      </code>
    </td>
    
    <td>
      <code>
        number | string
      </code>
    </td>
    
    <td>
      Positive integer server ID of an online player, or its numeric string. Local player indexes, ped handles and broadcast targets are not supported.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        customReason
      </code>
    </td>
    
    <td>
      <code>
        string?
      </code>
    </td>
    
    <td>
      Optional localized plain text from your integration. Leading/trailing spaces are trimmed. Must contain 1–120 Unicode characters, valid UTF-8 and no ASCII control characters.
    </td>
  </tr>
</tbody>
</table>

Returns `true` when the targeted client event is sent; `false` for an invalid/offline player or invalid reason. `true` does not confirm that the player died: the client's spawn-readiness, damage protection and death hooks still apply. Call this from a trusted server resource instead of killing the ped separately first.

The custom text appears in the paramedic diagnosis view while the patient is unconscious and on the death screen when cause information is enabled. It clears on revival. Omitting the reason or passing `nil` preserves the existing `suicide` reason. Custom text does not change injuries or treatment rules. See [Client Exports](/docs/jobs/ambulancejob/api/client-exports#killplayercustomreason) for the local-player version.

### `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).

```lua
-- Normal revive
exports["sky_ambulancejob"]:revive(playerId)

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

### `setGodmode(playerId, enabled)`

- **Purpose**: Enables or disables damage protection for the supplied player through a server-authoritative export.
- **Arguments**:

  - `playerId` (`number|string`): The server ID of the player.
  - `enabled` (`boolean`): `true` enables Godmode; `false` disables it.
- **Returns**: `boolean` (`true` when the state was applied, `false` for an invalid or offline target).

```lua
-- Enable Godmode
exports["sky_ambulancejob"]:setGodmode(playerId, true)

-- Disable Godmode
exports["sky_ambulancejob"]:setGodmode(playerId, false)
```

### `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).

```lua
exports["sky_ambulancejob"]:isDead(playerId)
```

### `getDeathState(playerId)`

- **Purpose**: Returns the server-authoritative death snapshot for the specified player, including phase, bleed-out timer, action availability, AI Medic state, and detected cause.
- **Arguments**:

  - `playerId` (`number|string`): The server ID of the player whose state should be read.
- **Returns**: `table|nil` — the death snapshot, or `nil` for an invalid or offline player.

```lua
local state = exports["sky_ambulancejob"]:getDeathState(playerId)
```

See [External Death Screen](/docs/jobs/ambulancejob/api/external-death-screen) for the complete
integration flow, state fields, client actions, and security requirements.

### `getStretcherModels()`

- **Purpose**: Returns the list of vehicle models configured as stretcher vehicles.
- **Returns**: `table` — array of model hashes used for stretcher transport.

```lua
local models = exports["sky_ambulancejob"]:getStretcherModels()
```
