# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xtdev.gitbook.io/xt-docs/paid-resources/prison-jobs/installation-and-usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
