> For the complete documentation index, see [llms.txt](https://xtdev.gitbook.io/xt-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xtdev.gitbook.io/xt-docs/paid-resources/prison-jobs/installation-and-usage.md).

# Installation & Usage

## Installation

1. Open the provided SQL and find the framework you are using, copy the correct SQL string.
2. Add the SQL to your database
3. Add the cleaning supplies item to your inventory

## Usage

### Entering & Exiting Prison

When entering or exiting prison, trigger the following exports.

```lua
-- Entering
exports['xt-prisonjobs']:InitPrisonJob()
-- Creates a new location for your prison job, if you have one

-- Exiting
exports['xt-prisonjobs']:CleanupPrisonJob()
-- Removes job related points, blips, etc
```

## Server Config Functions

### Initialize Jail Time

This function is only used if you're not using xt-prison. Use case is returning the playerdata that your prison resource uses. On load, it will set that metadata to the playerstate that is used in xt-prisonjobs. Reducing time properly is handled with the other functions.

This example is in the case of using QBCore. The function passes the `player` object by default

```lua
initJailTime = function(player)
    return player.PlayerData.metadata.injail
end,
```

### Reduce Time

This function is triggered to reduce your jail time. You should trigger events/functions for setting a new jail time for your prison resource.

```lua
reduceTime = function(source, setTime)
    return exports['xt-prison']:SetJailTime(source, setTime)
end,
```

### Check Out

This function is triggered when a player presses the `Check Out` button in the menu. This should trigger events/functions to release a player from prison.

```lua
checkOut = function(source)
    return lib.callback.await('xt-prison:client:exitJail', source, true)
end
```
