# qb-ambulancejob: EMS and hospital lifecycle

The official `qb-ambulancejob` manages hospital beds, death/last-stand state, injuries, EMS duty and recovery. This reference is pinned to [commit 19bb190](https://github.com/qbcore-fivem/qb-ambulancejob/tree/19bb190d7c41e6b79d836a45d7498bd3762d0bd4). It is not a complete patient-records database or arbitrary injury creation service.

## Installation

1. Install `qb-core`, `oxmysql` and the `PolyZone` modules used in the [manifest](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/fxmanifest.lua). Confirm `qb-inventory` and job/dispatch dependencies on your server.
2. Keep `qb-ambulancejob`'s `client/`, `server/`, `html/` and locales intact.
3. Check that `ambulance` is an actual job in QBCore shared jobs and that hospital locations exist in the config.
4. Test injuries, last stand, hospital transport, EMS interaction, bandages, first aid and reconnect on staging.

The upstream tree contains **no** packaged SQL file creating `player_meds` or `medical_records`. These were fabricated in the previous QBCore.net page; do not add them for a standard installation.

## Configuration

The current [`config.lua`](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/config.lua) includes:

| Key | Function |
| --- | --- |
| `Config.UseTarget` | Interaction behavior based on `UseTarget` convar |
| `Config.MinimalDoctors` / `DocCooldown` | Availability and cooldown for medical services |
| `Config.WipeInventoryOnRespawn` | Inventory handling on respawn |
| `Config.RespawnAtNearestHospital` | Hospital selection behavior |
| `Config.BillCost` | Medical service charge |
| `Config.DeathTime` / `ReviveInterval` / `MinimumRevive` | Death/respawn timing |
| `Config.HealthDamage` / `ArmorDamage` | Wound severity thresholds |
| `Config.Locations` | Hospitals, duty/spawn positions and other points |
| `Config.AuthorizedVehicles` | Allowed EMS vehicle list |

The file also contains wound, bleeding and damage-related settings. Do not use `Config.MedicalSupplies`, `Config.InjuryTypes` or `Config.AmbulanceSpawns` as if they were defined by this upstream revision.

## Real server export

The [server implementation](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/server/main.lua) exposes **one** server export:

~~~lua filename="server.lua"
local onDutyDoctors = exports['qb-ambulancejob']:GetDoctorCount()
print(('On-duty doctors: %d'):format(onDutyDoctors))
~~~

This is a doctor count, not a client-callable `RevivePlayer` export. The resource does **not** register `AddInjury`, `HealPlayer`, `TreatPatient` or `GetMedicalRecord` as server exports.

## Hospital events and callbacks

Internal server network events are named under **`hospital:server:`**, including `SendToBed`, `RespawnAtHospital`, `SetDeathStatus`, `SetLaststandStatus`, `TreatWounds`, `RevivePlayer` and `UseFirstAid`. These are not `qb-ambulancejob:server:playerDied` or `billPatient`.

Callbacks registered with QBCore include `hospital:GetDoctors`, `hospital:GetPlayerStatus` and `hospital:GetPlayerBleeding`.

The server also registers EMS commands such as `911e` and admin/medical commands including `revive`, `heal` and `aheal`. Check the installed QBCore ACE configuration before exposing privileged commands.

**Authorization warning:** Internal network events that heal, revive or change a player's death state can be dangerous if clients can trigger them without server-side proof of EMS/admin permission and allowed target. Do not treat existing client UI checks as an authorization boundary.

## Troubleshooting

| Symptom | First check |
| --- | --- |
| EMS duty count wrong | Real `GetDoctorCount` export and active ambulance job |
| Cannot revive a player | Correct event side, EMS permission and target status |
| Bleeding/injury effect persists | Last-stand, injury sync and death metadata |
| Player respawns at wrong hospital | `RespawnAtNearestHospital` and `Config.Locations` |
| Medic gear unusable | QBCore shared items, usable-item handlers, `qb-inventory` |
| No such export `RevivePlayer` | Upstream exports only `GetDoctorCount` |

## Update checklist

1. Verify installed `qb-ambulancejob`, `qb-core`, `qb-inventory` and police/hospital dependencies.
2. Test death/respawn on disconnected and reconnected test clients.
3. Audit revive/heal/admin operations against real ACE/job permissions.
4. Never import unrelated patient-record SQL without verifying its real owner.

## Sources

[Repository](https://github.com/qbcore-fivem/qb-ambulancejob/tree/19bb190d7c41e6b79d836a45d7498bd3762d0bd4) · [Server export/events](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/server/main.lua) · [Configuration](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/config.lua) · [Manifest](https://github.com/qbcore-fivem/qb-ambulancejob/blob/19bb190d7c41e6b79d836a45d7498bd3762d0bd4/fxmanifest.lua)

Related: [qb-policejob](/docs/resources/qb-policejob), [server authority](/docs/security/server-authority-checklist).
