# Exports & Usage

## 🖥️ Server Exports

These exports should be used from server-side scripts only.

***

### 🔒 AddPrisonerExternally

Jails a player and adds them to the prison system.

```lua
exports['dynyx_prison']:AddPrisonerExternally(serverId, sentence, charges, lifer, serviceType, previousSentence, fine, officerSr)
```

#### Parameters

* **serverId** *(number)*\
  Player’s server ID.
* **sentence** *(number)*\
  Sentence length in months.
* **charges** *(table | string)*\
  List or string describing the charges.
* **lifer** *(boolean)*\
  Whether the player is a lifer.
* **serviceType** *(string)*\
  `"prison"` or `"community_service"`.
* **previousSentence** *(number, optional)*\
  Used for sentence stacking.
* **fine** *(number, optional)*\
  Optional fine to apply.
* **officerSrc** *(number)*\
  Server ID of the officer/player performing the arrest.

***

### 🔓 ReleasePrisonerExternally

Releases a prisoner normally or marks them as escaped.

```lua
exports['dynyx_prison']:ReleasePrisonerExternally(citizenid, jailbreak, officerSrc)
```

#### Parameters

* **citizenid** *(string)*\
  Player’s unique citizen identifier.
* **jailbreak** *(boolean)*\
  `true` if the player escaped\
  `false` if released normally.
* **officerSrc** *(number)*\
  Server ID of the officer/player authorizing the release.

***

### ✏️ **ModifyPrisonerSentenceExternally**

Sets a new sentence time for a prisoner.

```lua
exports['dynyx_prison']:ModifyPrisonerSentenceExternally(citizenid, newTime)
```

**Parameters:**

* `citizenid` *(string)* – Player’s unique identifier
* `newTime` *(number)* – New sentence time in months

***

### 📅 **GetRemainingPrisonSentence**

Returns the current time remaining for a prisoner.

```lua
local time = exports['dynyx_prison']:GetRemainingPrisonSentence(citizenid)
```

**Returns:**

* *(number)* Time remaining in months
* `0` if prisoner not found

***

### 🧱 **GetPrisonCellData**

Returns prisoner's cell data.

```lua
local celldata = exports['dynyx_prison']:GetPrisonCellData(source)
```

**Returns**:

* **number** *(number)* – Prisoner’s assigned cell number
* **coords** *(vector3)* – Prisoner’s cell coordinates

***

### ✅ IsActivePrisoner

Checks if a player is currently an **active prisoner**.

```lua
local active = exports['dynyx_prison']:IsActivePrisoner(source)
```

Returns `true` only if the player is jailed **and** is **not escaped** and **not in community service**.

#### Returns:

* *(boolean)* `true` if the player is actively imprisoned
* *(boolean)* `false` if the player is not jailed, has escaped, or is in community service

***

{% hint style="info" %}
This directly matches:
{% endhint %}

* `IsPlayerJailed(citizenid)`
* `IsPlayerCommunityService(citizenid)`
* `IsPlayerEscaped(citizenid)`

***

### ✅ **IsPlayerJailed**

Checks if a player is currently serving a prison sentence.

```lua
local jailed = exports['dynyx_prison']:IsPlayerJailed(citizenid)
```

**Returns:**

* *(boolean)* `true` if jailed, `false` if not

***

### 🛠️ **IsPlayerCommunityService**

Checks if a player is currently serving community service.

```lua
local comserv = exports['dynyx_prison']:IsPlayerCommunityService(citizenid)
```

**Returns:**

* *(boolean)* `true` if serving community service, `false` if not

***

### 🚨 **IsPlayerEscaped**

Checks if a player has escaped from prison.

```lua
local escaped = exports['dynyx_prison']:IsPlayerEscaped(citizenid)
```

**Returns:**

* *(boolean)* `true` if escaped, `false` if not

***

## 🧑‍💻 Client Exports

These can be used from client-side scripts.

***

### 🏥 SendPlayerToInfirmary

Sends the player to a random infirmary bed, plays the healing sequence, and optionally revives the player.&#x20;

```lua
exports['dynyx_prison']:SendPlayerToInfirmary(chargePlayer)
```

**Parameters**

* `chargePlayer` *(boolean)*
  * `true` → Charges the player for treatment (if enabled in config)
  * `false` → Free treatment (recommended for death/respawn systems)

> Primarily used by ambulance or respawn systems to send incarcerated players who die to the prison infirmary.

### 📋 **OpenPrisonManageUI**

Opens the prison staff UI to view or manage prisoners.

```lua
exports['dynyx_prison']:OpenPrisonManageUI()
```

Requires the player to have a valid staff job.

***

### 🔨 **OpenPrisonJobsUI**

Opens the inmate job selection UI.

```lua
exports['dynyx_prison']:OpenPrisonJobsUI()
```

***

### 🔨 **OpenCorrectionsTabletUI**

Opens the correctional job tablet UI.

```lua
exports['dynyx_prison']:OpenCorrectionsTabletUI()
```

***

💡 **Tips**

* You can use these in custom commands, MDTs, police scripts, admin menus, or integrated job systems.
* All server-side exports use live data — no need to restart the script after changes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dynyx-scripts.gitbook.io/dynyx-scripts/prison/exports-and-usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
