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

# Departments

> Run several departments in one MDT, and decide which records each one can see.

One MDT can serve every department on your server: police, sheriff, state troopers, rangers, and more. Each department is a job from your framework.

## Add a department

A job needs to be **whitelisted** to open the MDT, and needs **permissions** so its officers can do something once it's open.

> [tab] Admin panel
>
> **1. Open Access**
>
> Run `/mdtadmin` and open **Access**.
>
> **2. Add the job**
>
> Under **Whitelisted jobs**, click **Add job** and pick the job from your framework.
>
> **3. Copy permissions**
>
> In **Start its permissions from**, pick an existing job, such as `police`, to copy its permissions. Choose **Nothing** to set them up yourself later.
>
> **4. Adjust permissions**
>
> Open **Permissions**, pick the new job, and fine-tune what each grade can do. See [Permissions](https://docs.redutzu.com/redutzu-mdt/guides/permissions.md).
>
> ![Add job dialog under Whitelisted jobs in the admin panel](https://mintcdn.com/redutzusscripts/jYySSRvwCjpWaAJk/images/guides/departments-whitelisted-jobs.webp?fit=max\&auto=format\&n=jYySSRvwCjpWaAJk\&q=85\&s=bd8234bbe0c5fdafe88b7f6a7fc9dfba)
>
> Adding a whitelisted job in the Access section
>
> Members get access right away. Removing a job takes access away immediately, but keeps its permissions in case you add it back.

> [tab] config.lua
>
> **1. Whitelist the job**
>
> ```lua config/config.lua theme={null}
> Config.WhitelistedJobs = {
>     ['police'] = true,
>     ['sheriff'] = true,
> }
> ```
>
> **2. Give it permissions**
>
> Copy the `police` block in `config/permissions.json` and rename it. The grade numbers must match the job's grades in your framework.
>
> ```json config/permissions.json theme={null}
> {
>     "police": { "0": ["dashboard.view", "incidents.view"] },
>     "sheriff": { "0": ["dashboard.view", "incidents.view"] }
> }
> ```
>
> **3. Restart**
>
> Restart `redutzu-mdt`.

> [!WARNING]
>
> Once you save the whitelisted jobs in the admin panel, the panel's list overrides `Config.WhitelistedJobs`. Keep managing jobs from the panel, or use **Reset section** to go back to the file.

### Department money

Fines are paid into the society account of the officer's department. Add each department to `Config.Society.Accounts`:

```lua config/config.lua theme={null}
Config.Society = {
    ...
    Accounts = {
        ['police'] = 'police',
        ['sheriff'] = 'sheriff',
    },
}
```

The key is the job, and the value is its society account in your banking script. You can also set this in `/mdtadmin`, under **Money**.

## Share or separate records

By default, every department sees every record. Turn on **department access** to decide which departments can open each record.

> [tab] Admin panel
>
> Run `/mdtadmin`, open **Access**, and turn on **Limit records by department**. Then choose:
>
> * **Record types it applies to:** which kinds of records follow department access.
> * **Visibility of new records:** what a new record starts with.
> * **Jobs that see every record:** departments that bypass the rules.
>
> ![Limit records by department turned on in the admin panel, with its options](https://mintcdn.com/redutzusscripts/jYySSRvwCjpWaAJk/images/guides/departments-record-access.webp?fit=max\&auto=format\&n=jYySSRvwCjpWaAJk\&q=85\&s=67632e40635e504f409985fefa7a25a3)
>
> Department access settings in the Access section

> [tab] config.lua
>
> ```lua config/config.lua theme={null}
> Config.DepartmentAccess = {
>     Enabled = true,
>
>     Records = {
>         incidents = true,
>         warrants = true,
>         bolos = true,
>         evidences = true,
>         announcements = true
>     },
>
>     DefaultVisibility = 'public', -- 'public', 'department' or 'assigned'
>
>     BypassJobs = { 'doj' }
> }
> ```

### Visibility

Every record gets one of three visibilities. Officers of the department that created it can change it on the record afterwards.

| Visibility | Who can open the record |
| - | - |
| `public` | Every department. |
| `department` | Only the department that created it. |
| `assigned` | The department that created it, plus the ones picked on it. |

Use `assigned` for joint operations. A police incident can be shared with the sheriff while staying hidden from everyone else.

![Visibility selector on a record, with departments assigned](https://mintcdn.com/redutzusscripts/jYySSRvwCjpWaAJk/images/guides/departments-record-visibility.webp?fit=max\&auto=format\&n=jYySSRvwCjpWaAJk\&q=85\&s=5259c423f4c4e5fd12f8e3eb3cbc9b34)

Choosing a record's visibility

### Record types

Only the types turned on in `Records` follow department access. The rest stay visible to every department. For announcements, it lets the author choose which departments see the post.

> [!NOTE]
>
> Citizens, vehicles, properties, and weapons are always shared. They describe people and things in the city, not department work.

### Jobs that see everything

Jobs in `BypassJobs` see and manage every record, whatever its visibility. Use it for chiefs of a joint command, internal affairs, or the court.

A bypass job still needs to be whitelisted and have permissions to open the MDT.

## Cross-department permissions

Some permissions reach beyond the officer's own department. Give them only to the ranks that oversee several departments.

| Permission | What it allows |
| - | - |
| `management.permissions.all` | Edit the rank permissions of any department. |
| `management.analytics.all` | See the analytics and finances of any department. |
| `employees.leaderboard.all` | See leaderboards across every department. |

## Check access in your scripts

Use the `CanAccessRecord` export on the server to check whether a player can open a record, with department access applied.

```lua server.lua theme={null}
local allowed = exports['redutzu-mdt']:CanAccessRecord(source, 'incident', 142)
```

The record type is `incident`, `warrant`, `bolo`, `evidence`, `citizen`, `vehicle`, `weapon`, or `property`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.