# Setup

## ESX

Download and ensure the latest `esx_addonaccount` from here: <https://github.com/esx-framework/esx_addonaccount>.

## QBCore

Instructions on how to setup job/society accounts with QBCore framework compatibility.

### `qb-banking`

If you are using `qb-banking`, all you need to do is download and ensure the latest version of `qb-banking` from here: <https://github.com/qbcore-framework/qb-banking>.

### `qb-management`

If you are using qb-management (old method), then follow these instructions.&#x20;

{% hint style="warning" %}
Latest `qb-management` does not manage job/society accounts. This is now handled by `qb-banking`. If you are using old qb-management, it's highly recommended to update to latest and utilize `qb-banking` instead.&#x20;
{% endhint %}

{% stepper %}
{% step %}

### Find the file to modify

Navigate to `qb-management/server/sv_boss.lua`.&#x20;
{% endstep %}

{% step %}

### Check for functions

Do `Ctrl + F` (search) for `GetAccount` or `AddMoney` or `RemoveMoney`. If they do not exist, then do not proceed further! Instead, ensure that you have latest [`qb-banking`](https://github.com/qbcore-framework/qb-banking) installed, as this resource now handles job/society accounts.&#x20;
{% endstep %}

{% step %}

### Insert new function

Scroll down all the way to the bottom and insert the following code:

```lua
--- Creates a management account for a job in qb-management.
---@param job_name string The name of the job to create the management account for.
---@param amount number|nil The initial balance of the account (defaults to 0 if not provided).
---@return boolean success Returns `true` if the account was created successfully, `false` otherwise.
function CreateManagementAccount(job_name, amount)
    -- Ensure a valid job name is provided
    if type(job_name) ~= "string" or job_name == "" then
        error("Invalid job_name provided")
    end

    amount = amount or 0 -- Default to 0 if no amount is provided

    -- Check if account already exists in cache
    if Accounts[job_name] then
        return Accounts[job_name] -- Account already exists, no need to create it again
    end

    -- Insert the new account into the database
    local insertSuccess = MySQL.insert.await('INSERT INTO management_funds (job_name, amount, type) VALUES (@job_name, @amount, @type)', {
        ['@job_name'] = job_name,
        ['@amount'] = amount,
        ['@type'] = 'boss'
    })

    if not insertSuccess then
        error("Database error: Failed to insert management account")
    end

    -- Store in local cache
    Accounts[job_name] = amount

    return Accounts[job_name]
end
exports("CreateManagementAccount", CreateManagementAccount)
```

{% endstep %}

{% step %}

### Complete

Restart your server and you'll now be able to create management account in runtime!&#x20;
{% endstep %}
{% endstepper %}

## Qbox

Download and ensure the latest version of `Renewed-Banking` from here: <https://github.com/Renewed-Scripts/Renewed-Banking/releases>.

If you are using another banking/management for job/shared accounts, then refer to [API](/resources/t1ger-mechanic/installation/job-account/api.md) for custom integrations on your own.&#x20;

If using `qb-management` (old version) with backwards compatibility, then see [#qb-management](#qb-management "mention").


---

# 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://docs.t1ger.net/resources/t1ger-mechanic/installation/job-account/setup.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.
