# Medical Help — documentation

> Heal and revive points for when no EMS is on duty.

- URL: https://xexstudio.com/docs/medical-help
- Version: 2.0.0
- Product page: https://xexstudio.com/scripts/medical-help
Heal and revive points for quiet hours. Each point only opens while the number of EMS on duty is at or below
its limit, so it never competes with your EMS players. ESX, QBCore and Qbox.

## Requirements

- [ox_lib](https://github.com/overextended/ox_lib)
- One framework: **ESX** (with `esx_ambulancejob`), **QBCore** (with `qb-ambulancejob`) or **Qbox** (with `qbx_medical`)
- OneSync (default on every modern server)

## Install

1. Drop `xex_medicalhelp` into your resources folder.
2. Add to `server.cfg` after your framework, ambulance job and ox_lib:
   ```cfg
   ensure xex_medicalhelp
   ```
3. Language: `setr ox:locale en` (or `es`).
4. Optional Discord log (never put it in `config.lua`, clients can read that file):
   ```cfg
   set xex_medicalhelp:webhook "https://discord.com/api/webhooks/..."
   ```

## How it works

- **Heal point:** stand on the marker and press E. Restores health (and clears injuries on QBCore/Qbox).
- **Revive point:** bring the downed player next to the point (use `/carry`) and press E.
- The server counts EMS on duty every 5 seconds. A point is open while that count is at or below its `maxEMS`.

## Configure

Everything lives in `config.lua`:

| Setting | What it does |
| --- | --- |
| `Config.Framework` | `auto`, or force `esx` / `qb` / `qbox` |
| `Config.EMSJobs` | Jobs that count as EMS |
| `Config.CountOffDuty` | Count EMS who are off duty |
| `Config.Account` | Account charged by default, or a list tried in order |
| `Config.Heal` / `Config.Revive` | Treatment duration, distance of the downed player to the point |
| `Config.Cooldown` | Seconds between two uses per player |
| `Config.Points` | Every point: type, location, `maxEMS`, price, account, allowed jobs/gangs, NPC, blip, marker |
| `Config.Carry` | `/carry` command, distance and whether only downed players can be carried |
| `Config.CanUse` | Optional server-side function for your own access rules |

## For developers

```lua
-- server: every completed heal or revive
AddEventHandler('xex_medicalhelp:used', function(source, kind, pointIndex, target, price) end)

-- server: EMS on duty as counted by this resource
local count = exports.xex_medicalhelp:GetEMSCount()
```

`bridge/server.lua` is open: adapt it if you use a custom framework, ambulance job or death system.

## Security

- The client never decides anything: the server checks access, EMS count, distance, the patient's state and
  the time the treatment took, and charges the price from the config.
- Carry pairs are kept on the server with a fixed animation; nobody can attach players from a distance.

## Upgrading from 1.x

`config.lua` changed. Copy your points into the new format (`HRPoints` → `Points`, `pointType` → `type`,
`location` → `coords`, `cost` → `price`, `whitelistedJobs` → `groups`, `NPCPed`/`NPCPedPosition` → `npc`).
Move the webhook to `server.cfg`.
