> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-police/install.md).

# Installation

Install CAS Advanced Police & Law System on a VORP or RSG RedM server: server.cfg order, items, pictures, database tables, admins and replacing vorp\_police, rsg-lawman and rsg-prison.

[Back to the guide](/script-documentation/cas-police/cas-advanced-police-and-law-system.md)

## 1. The folder

Put the `cas-police` folder in your server's resources, for example `resources/[cas]/cas-police`.

Keep the folder name `cas-police`. Other scripts call it by that name (`exports['cas-police']:...`), its events start with `cas-police:`, and the picture paths of the book use `nui://cas-police/...`.

## 2. server.cfg

Start cas-police after oxmysql, your framework and your inventory.

VORP:

```cfg
ensure oxmysql
ensure vorp_core
ensure vorp_inventory
# ... the rest of your VORP resources ...
ensure cas-police
```

RSG:

```cfg
ensure oxmysql
ensure ox_lib
ensure rsg-core
ensure rsg-inventory
# ... the rest of your RSG resources ...
ensure cas-police
```

oxmysql is a hard dependency in the manifest, so the server will not start cas-police without it.

Optional CAS scripts work in any start order:

* **CAS Radial Menu** (`cas-radialmenu`): cas-police adds its own wheel to it by itself (`Config.Radial`).
* **CAS Notification** on VORP: it takes over VORP's notifications, so the cas-police messages show in its look (`Config.Notify = 'framework'`, the default).
* **All In One RedM Cars** (`cas-car1910`) with the **Police Patrol Car Pack** (`cas-carpack-police`): the cars of the office garage (City Police Patrol, Sheriff County Patrol, Highway Patrol Pickup, Police Transport Van). Their sirens and beacons come with the car pack. The LAW plate and the full tank are set through RedM Cars. cas-police ships no car files. Without the pack, list your own car models in `Config.Garage.cars`, or turn the garage off with `Config.Garage.enabled = false`.
* **CAS Advanced Medical System** (`cas-medical`): when it runs, a prisoner who dies trying to escape is revived through it before he wakes in his cell. Without it the framework's own revive is used.

## 3. The items

The script uses three items.

| Item        | Label        | Weight (kg) | Usable | What it is for                                                             |
| ----------- | ------------ | ----------- | ------ | -------------------------------------------------------------------------- |
| `handcuffs` | Handcuffs    | 0.4         | no     | Needed to cuff only when `Config.Cuff.requireItem = true`                  |
| `lockpick`  | Lockpick     | 0.1         | no     | Picking the cuffs of a friend                                              |
| `mdt_book`  | Records Book | 0.6         | yes    | Opens the records book when `Config.Book.openMode` is `'item'` or `'both'` |

**VORP.** Run `install/items_vorp.sql` once on your server database, then restart the server. It uses `INSERT IGNORE`, so items you already have are left alone.

**RSG.** Nothing to do. With `Config.RSGRegisterItems = true` (the default) cas-police adds the three items to rsg-core at every start, and only the ones that are missing. If you turned that off, copy the three lines from `install/items_rsg.lua` into the item list of `rsg-core/shared/items.lua` and restart. That file is not loaded by the script, it is only there to copy from.

## 4. The pictures

Copy the three pictures from `install/images/` (`handcuffs.png`, `lockpick.png`, `mdt_book.png`) into the item image folder of your inventory. Keep any picture you already have with the same name.

| Inventory         | Folder                           |
| ----------------- | -------------------------------- |
| vorp\_inventory   | `vorp_inventory/html/img/items/` |
| rsg-inventory     | `rsg-inventory/html/images/`     |
| Another inventory | Its own item image folder        |

## 5. The database

There is no SQL to import for the script itself. On every start cas-police makes any table that is missing (`CREATE TABLE IF NOT EXISTS`) and adds new columns to tables made by an older version. All its tables start with `cas_police_`:

| Table                   | Holds                                                                           |
| ----------------------- | ------------------------------------------------------------------------------- |
| `cas_police_reports`    | Filed reports                                                                   |
| `cas_police_drafts`     | The report each lawman is writing (survives a relog)                            |
| `cas_police_warrants`   | Warrants and bounties, open and closed                                          |
| `cas_police_citizens`   | The file of every citizen (file number, description, photograph link)           |
| `cas_police_history`    | The record of every citizen (reports, warrants, fines, jail, captures, escapes) |
| `cas_police_penal`      | Penal code changes made inside the book                                         |
| `cas_police_notes`      | Patrol notes                                                                    |
| `cas_police_captures`   | Bounty capture receipts                                                         |
| `cas_police_jail`       | Prisoners serving time                                                          |
| `cas_police_members`    | The roll of every office, and who logged out on duty                            |
| `cas_police_ledger`     | Office ledger balances                                                          |
| `cas_police_ledger_log` | Every ledger entry                                                              |
| `cas_police_locker_log` | Every item put in or taken from an office locker                                |
| `cas_police_badges`     | Each lawman's badge placement                                                   |
| `cas_police_duty_days`  | Minutes on duty per day (for the pay roll)                                      |
| `cas_police_paydue`     | Pay waiting for members who were offline on pay day                             |

## 6. Admins

Admins can open the records book, the marshal's desk and (with `/mdt hunter`) the hunter's board without a law job, pass every rank and duty check, and use `/lawcoords`. A player is an admin when any of these is true:

* He has the ace `caspolice.admin` (the name is `Config.AdminAce`).
* His steam hex is in `Config.Admins` or in `Config.Book.admins`.
* He is a framework admin: VORP group `admin`, `superadmin` or `god`, or RSG permission `admin` or `god`.

Give the ace to your admin group in `server.cfg`:

```cfg
add_ace group.admin caspolice.admin allow
```

Penal code editors are a separate list (`Config.Book.penalCodeEditors`). Admins can always edit the penal code.

## 7. Replacing old scripts

cas-police does the job of the stock law scripts. Running both makes them fight over the same keys and players, so stop the old ones. The console warns you at start when one of them is still running.

### VORP

Stop `vorp_police` (remove its `ensure` line).

What cas-police keeps working for other scripts:

* The `isPoliceDuty` state bag on the player. Billing, robbery and shop scripts read it to see a lawman on duty.
* While `vorp_police` is not running, cas-police answers the command names radial menus call on it: `/callpolice`, `/cancelPoliceAlert`, `/finishPoliceAlert`, `/Drag`, `/checkjailtime` and `/policeMenu`. See [Commands](/script-documentation/cas-police/commands.md).

**CAS Radial Menu.** If your radial menu config still has the old vorp\_police "Sheriff" wheel (id `duty.law` inside "Law & Aid"), you can remove it or comment it out: cas-police brings its own lawman wheel there. Leaving it does no harm, its buttons still work because cas-police answers the old commands. Keep the "Call the Law" and "Cancel the Law" slots for citizens; they run `/callpolice` and `/cancelPoliceAlert`.

### RSG

Stop `rsg-lawman` and `rsg-prison` (remove their `ensure` lines).

What cas-police keeps working for other scripts:

* The `isPoliceDuty` state bag on the player.
* The rsg-core player metadata `ishandcuffed` (true while cuffed) and `injail` (minutes left).
* The callback `rsg-lawman:server:getlaw`, so robberies and shops that ask how many lawmen are on duty still get an answer.
* The duty is also set on the rsg-core job (`SetJobDuty`), so scripts that read the rsg-core duty see it too.
* The law buttons of rsg-radialmenu: **Cuff**, **Escort**, **Jail** (opens the booking sheet), **Emergency Button** (a "Lawman down" alert), **Badge** (`/lawbadge`) and **Search** (`/searchplayer`).

The callback and the radial menu buttons only hook in while `rsg-lawman` itself is not running.

### Hogtie and search scripts

Hogtie and search are built in and cover every player. If you run a separate hogtie or search script, remove it too.

## 8. The first start

Start the server and watch the console. A good start prints one line:

```
[cas-police] running on VORP Core, 65 charges in the penal code.
```

On RSG it reads `running on RSG Core`. The number is the size of your penal code.

Lines you may see instead:

| Console line                                                             | What to do                                                                                                     |
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `no supported framework detected (VORP or RSG), script stopped.`         | vorp\_core or rsg-core did not start within a minute, or starts after cas-police. Fix the order in server.cfg. |
| `oxmysql is missing: the records book, jail and society need it.`        | Add `ensure oxmysql` before cas-police.                                                                        |
| `could not make a table: ...`                                            | The database user cannot create tables. Give it the rights, or check the oxmysql connection string.            |
| `vorp_police is running next to cas-police.` (or rsg-lawman, rsg-prison) | Stop that script.                                                                                              |

## 9. A first test

1. Give yourself a law job that is listed in `Config.Offices` (for example `sheriff`).
2. Walk into a sheriff's office of the base game and hold **E** at the duty prompt.
3. Type `/mdt`. The records book opens.
4. Face another player and press **F6**. The game's arrest plays on both of you and he ends up in cuffs.

Then read [Configuration](/script-documentation/cas-police/configuration.md) and set the offices, jails and points for your map. `/lawcoords` prints where you stand, ready to paste.

## Updating

The config, the language files, the framework bridges and the install files are open (`config/`, `locales/`, `server/bridge/`, `install/`). When you update, keep your own `config/` and `locales/` and compare them with the new ones for new settings.
