> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaworks.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# In-game usage

In this section I will explain how to use the script in game by a player and admin standpoint.

## Player (Doctor)

A player with the right job will be able to access the Medical UI, along with some other restricted items, specified by the `allowedJobs` table in the [items configuration file](/scripts/doctorjob/configuration/items).

### Medical UI

The medical UI can be accessed in multiple ways:

* **Player Targeting:** By default in RedM (and RDR2) it's possible to target other players by holding the right mouse button. By doing so you'll have access to a prompt menu in the bottom right corner. If you're close enough (defined in the script's config) you'll be able to see the visit prompt.
* **Medical Bed:** By being close enough to a configured medical bed you'll be able to access the visit menu prompt.
* **Visit command (optional):** If enabled/configured, you can open the Medical UI through `Config.visitCommand` (commonly `/visit`).
  If you prefer a custom selector, you can also call the server event `mega_doctorjob:visit` and pass the target's server id.
  Example with NPlayerSelector integration:
  ```lua theme={null}
  RegisterCommand("visit", function(source, args, rawCommand)
      NPlayerSelector:onPlayerSelected(function (data)
          TriggerServerEvent('mega_doctorjob:visit', data.id)       
          NPlayerSelector:deactivate()
      end)
      NPlayerSelector:setRange(1) -- <- set this to the desired range
      NPlayerSelector:activate()   
  end)
  ```

### Treating diseases

There are two main ways diseases get treated:

* **Through the Medical UI** (doctor treating a patient)
* **Through items** (see `MedicineItems` in [Items.lua](/scripts/doctorjob/configuration/items))

Medicine items can be configured to cure specific diseases with a probability, and can optionally expire after a duration.

Typical doctor workflow:

1. Open the Medical UI on the patient (targeting or medical bed).
2. Review the patient's active diseases.
3. Apply the appropriate treatment (UI action and/or item), based on what you configured in `MedicineItems`.
4. Re-check the patient status to confirm the disease is healed (or improved).

### Treating injuries (bone damage)

Doctorjob V2 can track **injury/bone damage** separately from diseases.

* Bone damage tracking is controlled by [DamageLogger.lua](/scripts/doctorjob/configuration/damagelogger) (`Config.boneDamageLogger.enabled`).
* When enabled, the script assigns damage to a **specific bone/body part** and stores it in the script's injury system.
* The bone injury system is **not the same** as actual ped health damage.

#### How damage is assigned (high-level)

* When a player takes damage, the script determines which bone/body part was hit.
* The raw damage is converted to a **normalized** basis (typically 0–100). This is important because raw health deltas can differ from player to player (e.g., due to different `MaxHealth`).
* The script also determines a **damage type** from the weapon mapping in [DamageTypes.lua](/scripts/doctorjob/configuration/damagetypes) (`Config.weaponToDamageType`), with a `default` fallback.
* It then assigns the normalized damage to the bone that got hit and stores an injury entry for that body part with a numeric damage value and a `damageType`.

#### How injuries are treated

* **Light injuries** can be treated with configured `HealItems` (see [Items.lua](/scripts/doctorjob/configuration/items)).

In practice, the doctor opens the Medical UI on a patient, selects the affected body part, and applies the available treatment steps/items until the injury is resolved.

Typical injury healing flow:

1. Open the Medical/Inspect UI on the patient/yourself.
2. Identify which body part(s) are injured.
3. Apply the available treatment action(s).

## Inspect UI

The Inspect UI is a lightweight version of the Medical UI.

* It can be opened via the `Config.inspectCommand` chat command (commonly `/inspect`).
* It is available to **everyone**, including normal players.

### Self-tending

Normal players can use the Inspect UI to **self-tend** their own injuries, when they have an allowed healing item in their inventory.

This behavior depends on your configuration in [Items.lua](/scripts/doctorjob/configuration/items) (for example, which `HealItems` are available and whether they are job-restricted).

<Info>
  Inspect remains "limited" compared to the full Medical UI: it is intended for quick checks/self-care and does not replace the full doctor system.
</Info>

## Commands

These are the chat commands exposed by Doctorjob. Command names can be customized via [Config.lua](/scripts/doctorjob/configuration/config).

### Player commands

* **Inspect:** `Config.inspectCommand` (commonly `/inspect`)
  * Opens the Inspect UI.
  * Available to everyone (normal players can self-tend if configured and they have an allowed healing item).

* **Visit:** `Config.visitCommand` (commonly `/visit`)
  * Opens the full Medical UI on a target (typically restricted to medical jobs).
  * The built-in implementation uses a player selector (no arguments).

* **Request help:** `Config.alertCommand`
  * Creates a help request/alert (subject to cooldown and dead-player rules).

* **Clear route:** `Config.clearAlertCommand`
  * Clears the GPS route created by alerts.

### Admin commands

* `/giveDisease <diseaseId> <id>`: Gives a player a disease (fails if the player has immunity for that disease).
* `/healDisease <diseaseId> <id>`: Heals a player's disease.
* `/giveImmunity <diseaseId> <id> [durationSeconds]`: Grants immunity to a disease.
  * `durationSeconds` is optional. Use `-1` (or omit) for permanent immunity.
* `/removeImmunity <diseaseId> <id>`: Removes immunity to a disease.
* `/dload`: Reload character data without quitting game. (use only in dev environments, not recommended for live servers)
* `/dsave`: Force-save all online players to the database.

### Job-restricted commands

* `Config.openAlertMenuCommand`
  * Opens the alerts menu for medical jobs (doctors) so they can view/respond to help requests.
