# Installation & Usage

## Installation

1. Add the prison gates to your ox\_doorlock (you'll need the names of the doors you set)
2. Configure your config files found in the configs folder
3. Setup the doorlock names you created in the prison break config. This is to be sure it unlocks the correct door when a terminal is hacked

### Commands

`/jail` - Send player to jail (toggleable command)\
`/jailtime` - Check your jail time\
`/prisoners` - View the prison roster if you're a police officer

## Usage

### Check if Player is Lifer

Check if a player is a lifer by using their `source`

```lua
exports['xt-prison']:isLifer(source)
```

### Set Player Jail Time

These are not used to send a player to jail, but to modify their jail time while they are in jail.

#### Client

```lua
local newTime = 100
local setTime = lib.callback.await('xt-prison:server:setJailStatus', false, newTime)
if setTime then
    print('jail time set')
end
```

#### Server

```lua
local newTime = 100
local setTime = exports['xt-prison']:SetJailTime(newTime)
if setTime then
    print('jail time set')
end
```

### Send Player to Jail

In order to properly send a player to jail, use the following callback. Pass the target player's source and the intended jailing time.

#### Server

```lua
local sent = lib.callback.await('xt-prison:client:enterJail', targetSource, setTime)
if sent then
    lib.notify(source, {
        title = 'Sent Player to Jail'
    })
end
```

### Unjail Player

To properly unjail a player, use the following callback. `isUnjailed` is passed as a `boolean` to release the player and ignore their existing jail time. Usually `true`

#### Server

```lua
local unjailed = lib.callback.await('xt-prison:client:exitJail', isUnjailed)
if unjailed then
    lib.notify(source, {
        title = 'Unjailed Player'
    })
end
```
