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

# Doctorjob API [V2]

> API reference for the new version of Doctorjob

Welcome to the **Doctorjob v2 API** documentation. The redesigned API is strictly divided between **Client-side** and **Server-side** environments to offer clear, unified entry points for interacting with the script's core mechanics.

## How to Import

Both Client and Server APIs are exported under the same name. Simply import them in your scripts using:

```lua theme={null}
local API = exports['mega_doctorjob']:API()
```

***

## Client API

### Diseases Management

Interact with diseases locally.

* **`API.Diseases.Get(diseaseId)`**
  Retrieves a specific disease instance.
  * **Parameters:** `diseaseId` (string)
  * **Returns:** [`Disease`](/scripts/doctorjob/custom-diseases/disease-class) object or `nil`

* **`API.Diseases.GetAll()`**
  Retrieves all diseases currently tracked for the local player.
  * **Returns:** `table` of all diseases

* **`API.Diseases.Give(diseaseId)`**
  Activates a specific disease on the local player.
  * **Parameters:** `diseaseId` (string)

* **`API.Diseases.Heal(diseaseId, completeHeal)`**
  Heals a specific disease (optionally fully curing it).
  * **Parameters:**
    * `diseaseId` (string)
    * `completeHeal` (boolean | nil) - If `true`, completely cures the disease immediately.

### Patient Management

* **`API.Patient.Get()`**
  Returns the active patient object for the local player.
  * **Returns:** `Patient` object

### Utility Functions

* **`API.Utils.GetBodyPerceivedTemperature(ped, localTemperature)`**
  Calculates the perceived temperature of a ped based on the environment and their clothing.
  * **Parameters:**
    * `ped` (number) - The entity ID of the ped.
    * `localTemperature` (number) - The ambient temperature.
  * **Returns:** `number`

***

## Server API

The unified Server API provides a single entry point for all script functionality related to server-side logic and sync.

### Diseases Management

* **`API.Diseases.Give(playerId, diseaseId)`**
  Gives a specific disease to a player, respecting any immunities they might have.
  * **Parameters:**
    * `playerId` (number) - The server ID of the player.
    * `diseaseId` (string)
  * **Returns:** `boolean` (`true` if successful, `false` if player not found or immune).

* **`API.Diseases.Heal(playerId, diseaseId, completeHeal)`**
  Heals a disease for a specific player.
  * **Parameters:**
    * `playerId` (number) - The server ID of the player.
    * `diseaseId` (string)
    * `completeHeal` (boolean | nil) - Whether to completely heal it.
  * **Returns:** `boolean` (`true` if successful, `false` otherwise).

### Patient Management

* **`API.Patient.Get(playerId)`**
  Retrieves the patient data for a specific player.
  * **Parameters:** `playerId` (number)
  * **Returns:** `Patient` object or `nil`

### Immunity Management

* **`API.Immunity.Give(playerId, diseaseId, duration)`**
  Grants a player immunity to a specific disease for a set duration.
  * **Parameters:**
    * `playerId` (number)
    * `diseaseId` (string)
    * `duration` (number) - Duration of the immunity (pass `-1` or omit for permanent).
  * **Returns:** `boolean`

* **`API.Immunity.Remove(playerId, diseaseId)`**
  Strips the immunity for a specific disease from a player.
  * **Parameters:**
    * `playerId` (number)
    * `diseaseId` (string)
  * **Returns:** `boolean`

### Bones Management

* **`API.Bones.Set(playerId, boneId, damage, damageType)`**
  **Sets** the damage value for a specific bone for a player in the script's logic. **Note:** This *will not* apply actual health damage to the player's ped. You must apply the health damage yourself using natives.
  * **Parameters:**
    * `playerId` (number)
    * `boneId` (number) - The ID of the bone.
    * `damage` (number) - The amount of damage.
    * `damageType` (string | nil) - Type of damage applied.
  * **Example:**
    ```lua theme={null}
    -- PSEUDOCODE:
    -- 1) Apply actual ped health damage where you have access to the ped (usually client-side)
    -- ApplyDamageToPed(PlayerPedId(), damage, false)

    -- 2) Then register/overwrite the bone damage in the script (server-side)
    API.Bones.Set(playerId, boneId, damage, 'bruise')
    ```

* **`API.Bones.Clear(playerId, boneId)`**
  Clears any damage taken on a specific bone.
  * **Parameters:**
    * `playerId` (number)
    * `boneId` (number)

* **`API.Bones.Get(playerId, boneId)`**
  Retrieves the damage data for a specific bone.
  * **Parameters:**
    * `playerId` (number)
    * `boneId` (number)
  * **Returns:** `BoneDamage` object or `nil`

### Classes

#### BoneDamage

**Properties:**

* `damageType` (string) - The categorical type of damage applied to the bone (e.g., 'bruise', 'cut', 'projectile').
* `damage` (number) - The severity/amount of damage the bone has received.
