> For the complete documentation index, see [llms.txt](https://mango-5m.gitbook.io/mango5m-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mango-5m.gitbook.io/mango5m-docs/resources/mango-prison/getting-started/installation.md).

# Installation

Install Mango Prison — requirements, database, jobs, items and server.cfg.

## Requirements

| Required                                    | Optional (auto-detected)                                                   |
| ------------------------------------------- | -------------------------------------------------------------------------- |
| ESX Legacy, QBCore or Qbox                  | **mango\_notify** — default notifications (falls back to ox\_lib)          |
| [ox\_lib](https://overextended.dev/ox_lib)  | **ox\_doorlock** — cell doors and lockdowns                                |
| [oxmysql](https://overextended.dev/oxmysql) | **ox\_inventory** — full metadata property storage, evidence, cell stashes |
| ox\_target **or** qb-target                 | **mango\_mdt** or **ps-dispatch** — police dispatch for escapes and riots  |
| Bolingbroke Prison Interior MLO             | **illenium-appearance** — full appearance snapshots                        |
|                                             | **screenshot-basic** — intake mugshots                                     |

{% stepper %}
{% step %}

### Import the database

Run both files from the `sql/` folder against your server database:

* `install.sql` — inmates, property, records, audit log and state tables (safe to re-run)
* `jobs.sql` — creates the **Corrections (`doc`)** job with four grades and the **`prisoner`** job (ESX; QB/Qbox entries are in the file's comments)
  {% endstep %}

{% step %}

### Add the inventory items

For ox\_inventory, add to `ox_inventory/data/items.lua`:

```lua
['prison_key']   = { label = 'Prison Key',   weight = 100, stack = false, close = true },
['prison_scrip'] = { label = 'Prison Scrip', weight = 0,   stack = true },
['screwdriver']  = { label = 'Screwdriver',  weight = 100 },
['hacksaw']      = { label = 'Hacksaw',      weight = 500 },
```

| Item                      | Used for                                                                                           |
| ------------------------- | -------------------------------------------------------------------------------------------------- |
| `prison_key`              | **Opens every prison door.** Give it to corrections staff, or let it be stolen for an escape route |
| `prison_scrip`            | Wages from prison jobs, spent at the commissary                                                    |
| `screwdriver` / `hacksaw` | The default [escape](/mango5m-docs/resources/mango-prison/configuration/escapes.md) requirements   |

All four names are config-referenced only — rename them freely.
{% endstep %}

{% step %}

### Set up the doors (ox\_doorlock)

Import your Bolingbroke door pack into ox\_doorlock, then grant access. Every door should allow **the `doc` job** and **anyone holding a `prison_key`**:

```json
"groups": {"doc": 0}, "items": ["prison_key"]
```

To apply that to every door already in your database in one go:

```sql
UPDATE `ox_doorlock`
SET `data` = JSON_MERGE_PATCH(`data`, '{"groups":{"doc":0},"items":["prison_key"]}');
```

Then `restart ox_doorlock`.

{% hint style="warning" %}
Back up the table first. `JSON_MERGE_PATCH` **merges** `groups` (existing jobs are kept) but **replaces** `items` wholesale — any per-door item requirement you already had is overwritten. Everything else in each door's JSON (coords, model, state, heading) is untouched.
{% endhint %}

Listing the item as a plain string means **possession opens the door and the key is not consumed**.

`config/doors.lua` already maps **179 Bolingbroke doors** — cell gates, wing entrances, yard, medical, visitation and the full-prison group — so if you are using the standard door pack there is nothing more to do. On boot you should see:

```
[mango_prison] doorlock: mapped 179 door name(s)
```

Using a different MLO or door pack? See [Doors & Lockdowns](/mango5m-docs/resources/mango-prison/configuration/doors-and-lockdowns.md) — the built-in door inspector names each door as you point at it.
{% endstep %}

{% step %}

### Remove your old jail script

Stop and remove `esx_jail`, `qb-prison`, or any other jail resource. Mango Prison intercepts their events (so your existing police job keeps working) and warns at boot if one is still running.
{% endstep %}

{% step %}

### Ensure the resource

After your framework, ox\_lib and inventory:

```
ensure mango_prison
```

{% endstep %}

{% step %}

### Test it

Give yourself the `doc` job (or police), then from the server console:

```
prison jail <your id> 5 Testing
```

You should ride the bus in, get prison blues and a cell, and see "sentenced to 5 months". Walk to a terminal (booking office) and open the dashboard. Release yourself with `prison release <id>` — your items, cash, job and clothes come back.
{% endstep %}
{% endstepper %}

{% hint style="success" %}
Coordinates ship pre-derived from the Bolingbroke MLO's door positions. Walk the facility once with `Config.Debug = true` (zones draw in-world) and nudge anything that doesn't line up — see [Locations & Zones](/mango5m-docs/resources/mango-prison/configuration/locations-and-zones.md).
{% endhint %}
