# Jail System

## JailPlayer

Use following export to jail some player.

```lua
exports['p_policejob']:JailPlayer(officerId, data)
```

* officerId: `number`
  * Existing officer id
* data: `table`
  * player: `number`
  * jail: `number`
  * fine: `number`
  * reason: `string`
  * offenses?: `{ [string]: offenseData }`

### offenseData

* fine: `number`
* label: `string`
* jail: `number`
* count: `number`

Return:

* state: `boolean` or `nil`

{% hint style="warning" %}
Offenses are only required to display it properly in our Police MDT.
{% endhint %}

***

## JailPlayers

Use following export to jail few players at the same time.

```lua
exports['p_policejob']:JailPlayers(officerId, data)
```

* officerId: `number`
  * Existing officer id
* data: `table`
  * players: `{ [index]: { identifier: string } }`
  * jail: `number`
  * fine: `number`
  * reason: `string`
  * offenses?: `{ [string]: offenseData }`

### offenseData

* fine: `number`
* label: `string`
* jail: `number`
* count: `number`

Return:

* state: `boolean` or `nil`

{% hint style="warning" %}
Offenses are only required to display it properly in our Police MDT.
{% endhint %}

***

## Jail Command

Use following command to jail player \[required permissions in config]

```lua
/jail targetId months
```

* targetId: `number`
  * Existing player server id
* months: `number`
  * Amount of months in jail

***

## Unjail Player

Use following export to unjail player.

```lua
exports['p_policejob']:UnJailPlayer(playerId, targetId)
```

* playerId: `number or nil`
  * Existing player server id
* targetId: `number`
  * Existing player server id in jail

***

## Unjail Command

Use following command to unjail player \[required permissions in config].

```lua
/unjail targetId
```

* targetId: `number`
  * Existing player server id in jail

***

## Shorten Jail

Use following export to shorten player jail.

```lua
exports['p_policejob']:ShortenJailPlayer(playerId, targetId, months)
```

* playerId: `number or nil`
  * Existing player server id
* targetId: `number`
  * Existing player server id in jail
* months: `number`
  * Amount of months to shorten

***

## Shorten Jail Command

Use following command to shorten jail player \[required permissions in config].

```lua
/shortjail targetId months
```

* targetId: `number`
  * Existing player server id in jail
* months: `number`
  * Amount of months to shorten

***

## inJail

Check if player is currently in jail.

```lua
Player(playerId).state.inJail
```

* playerId: `number`
  * Existing player server id

Return:

* state: `boolean`

## getPlayerJudgment

Check player remaining amount of months in jail.

```lua
exports['p_policejob']:getPlayerJudgment(playerId)
```

* playerId: `number`
  * Existing player server id

Return:

* months: `number` or `0`
