> For the complete documentation index, see [llms.txt](https://wiki.qfdevelopers.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.qfdevelopers.com/scripts/editor-7/configuration.md).

# Configuration

## Languages

You can set the language of the script in the configuration file.

* `en`: English
* `fr`: French
* `pl`: Polish
* `de`: German
* `es`: Spanish

<figure><img src="/files/ig9o7wm8oX8fWWbPFHXs" alt=""><figcaption></figcaption></figure>

## Exports (Server-side)

<table><thead><tr><th width="249">Category</th><th>Export Name</th><th>Description</th></tr></thead><tbody><tr><td>Creation</td><td><code>CreateInvoice</code></td><td>Create an invoice from one player to another</td></tr><tr><td>Creation</td><td><code>CreateInvoiceForSociety</code></td><td>Create an invoice addressed to a company/society</td></tr><tr><td>Data Retrieval</td><td><code>GetPlayerInvoices</code></td><td>Retrieve all invoices related to a player</td></tr><tr><td>Data Retrieval</td><td><code>GetInvoiceById</code></td><td>Fetch a single invoice by ID</td></tr><tr><td>Data Retrieval</td><td><code>GetUnpaidInvoicesCount</code></td><td>Count unpaid invoices for a player</td></tr><tr><td>Data Retrieval</td><td><code>HasUnpaidInvoices</code></td><td>Quick boolean check for unpaid invoices</td></tr><tr><td>Data Retrieval</td><td><code>GetSocietiesList</code></td><td>Get all registered societies</td></tr><tr><td>Management</td><td><code>ForcePayInvoice</code></td><td>Force the payment of an invoice (admin only)</td></tr><tr><td>Management</td><td><code>CancelInvoice</code></td><td>Cancel an invoice (admin only)</td></tr><tr><td>Statistics</td><td><code>GetPlayerStatistics</code></td><td>Get billing statistics for a player</td></tr><tr><td>Analytics</td><td><code>AddIncomeToChart</code></td><td>Add an income entry to the analytics chart</td></tr></tbody></table>

### 1. CreateInvoice

**Description:**\
Creates a new invoice from one player to another.

**Parameters:**

| Name           | Type   | Required | Description                                        |
| -------------- | ------ | -------- | -------------------------------------------------- |
| `sourcePlayer` | number | yes      | ID of the player creating the invoice              |
| `targetPlayer` | number | yes      | ID of the player receiving the invoice             |
| `items`        | table  | yes      | Table of billed items `{ label, price, quantity }` |
| `invoiceType`  | string | yes      | Type of invoice (`personal` or `society`)          |

**Returns:**\
`boolean` — true if successfully created.

**Example:**

```lua
exports.qfbilling:CreateInvoice(
    source, 
    targetId, 
    {
        { label = 'Traffic Violation', price = 500, quantity = 1 },
        { label = 'Parking Fee', price = 200, quantity = 1 }
    },
    'personal'
)
```

### 2. CreateInvoiceForSociety <a href="#id-2-createinvoiceforsociety" id="id-2-createinvoiceforsociety"></a>

**Description:**\
Creates an invoice addressed to a company or registered society.

**Parameters:**

| Name            | Type   | Required | Description                                      |
| --------------- | ------ | -------- | ------------------------------------------------ |
| `sourcePlayer`  | number | yes      | ID of the player issuing the invoice             |
| `targetSociety` | string | yes      | Target society name (e.g. `police`, `ambulance`) |
| `items`         | table  | yes      | Items list `{ label, price, quantity }`          |
| `invoiceType`   | string | no       | Defaults to `society`                            |

**Example:**

```lua
exports.qfbilling:CreateInvoiceForSociety(
    source,
    'mechanic',
    {
        { label = 'Vehicle Service', price = 5000, quantity = 1 },
        { label = 'Spare Parts', price = 1200, quantity = 2 }
    }
)
```

### 3. GetPlayerInvoices <a href="#id-3-getplayerinvoices" id="id-3-getplayerinvoices"></a>

**Description:**\
Retrieves all invoices belonging to a player (personal, society, and sent).

**Parameters:**

| Name       | Type     | Required | Description                                      |
| ---------- | -------- | -------- | ------------------------------------------------ |
| `source`   | number   | yes      | Player ID                                        |
| `callback` | function | yes      | Called with `invoices` table and `money` balance |

**Example:**

```lua
exports.qfbilling:GetPlayerInvoices(source, function(invoices, money)
    print("Wallet: " .. money)
    print("Personal invoices: " .. #invoices.personal)
    print("Society invoices: " .. #invoices.society)
end)
```

### 4. GetInvoiceById <a href="#id-4-getinvoicebyid" id="id-4-getinvoicebyid"></a>

**Description:**\
Fetches all details of a specific invoice by its unique ID.

**Callback Result Example:**

```lua
{
  id = 42,
  sendername = "John Doe",
  sendersociety = "police",
  targetname = "Jane Roe",
  amount = 1500,
  items = { { label = "Fine", price = 1500, quantity = 1 } },
  status = "unpaid"
}
```

**Example:**

```lua
exports.qfbilling:GetInvoiceById(42, function(invoice)
    if invoice then
        print("Invoice ID:", invoice.id)
        print("Total:", invoice.amount)
        print("Status:", invoice.status)
    end
end)
```

### 5. GetUnpaidInvoicesCount <a href="#id-5-getunpaidinvoicescount" id="id-5-getunpaidinvoicescount"></a>

**Description:**\
Gets the count of unpaid invoices for a player along with summary data.

**Example:**

```lua
exports.qfbilling:GetUnpaidInvoicesCount(source, function(count, data)
    if count > 0 then
        print("You have " .. count .. " unpaid invoices.")
    end
end)
```

### 6. HasUnpaidInvoices <a href="#id-6-hasunpaidinvoices" id="id-6-hasunpaidinvoices"></a>

**Description:**\
Lightweight boolean check to quickly verify if a player has outstanding invoices.

**Example:**

```lua
exports.qfbilling:HasUnpaidInvoices(source, function(hasUnpaid)
    if hasUnpaid then
        print("Player cannot proceed - unpaid invoices detected.")
    else
        print("No outstanding debt.")
    end
end)
```

### 7. GetSocietiesList <a href="#id-7-getsocietieslist" id="id-7-getsocietieslist"></a>

**Description:**\
Retrieves all available societies from the database.

**Callback Example:**

```lua
exports.qfbilling:GetSocietiesList(source, function(societies)
    for _, society in ipairs(societies) do
        print(society.label .. " (" .. society.name .. ")")
    end
end)
```

### 8. ForcePayInvoice (Admin Only) <a href="#id-8-forcepayinvoice-admin-only" id="id-8-forcepayinvoice-admin-only"></a>

**Description:**\
Allows administrators to enforce payment of any invoice.

**Example:**

```lua
exports.qfbilling:ForcePayInvoice(invoiceId, playerId, function(success, message)
    print(message)
end)
```

### 9. CancelInvoice (Admin Only) <a href="#id-9-cancelinvoice-admin-only" id="id-9-cancelinvoice-admin-only"></a>

**Description:**\
Cancels a given invoice (admin privilege required).

**Example:**

```lua
exports.qfbilling:CancelInvoice(invoiceId, function(success)
    if success then
        print("Invoice has been successfully cancelled.")
    end
end)
```

### 10. GetPlayerStatistics <a href="#id-10-getplayerstatistics" id="id-10-getplayerstatistics"></a>

**Description:**\
Returns detailed billing statistics (daily, weekly, monthly).

**Example:**

```lua
exports.qfbilling:GetPlayerStatistics(source, function(data)
    print("Invoices Today: " .. data.personal.stats.totalInvoices.today)
    print("Monthly Income: " .. data.personal.stats.totalIncome.month)
end)
```

### 11. AddIncomeToChart <a href="#id-11-addincometochart" id="id-11-addincometochart"></a>

**Description:**\
Adds income data to analytics. This function updates the internal income chart.

**Example:**

```lua
exports.qfbilling:AddIncomeToChart("char1123456", "mechanic", 5000)
```

### Data Structures <a href="#data-structures" id="data-structures"></a>

| Data Type       | Description                                         |
| --------------- | --------------------------------------------------- |
| `invoiceType`   | `personal`, `society`                               |
| `invoiceStatus` | `unpaid`, `paid`, `request`, `rejected`, `canceled` |
| `item`          | `{ label, price, quantity }`                        |

## Other

### 1. Framework Detection <a href="#id-1-framework-detection" id="id-1-framework-detection"></a>

Detect which framework your server is running to enable integration automatically.

```lua
Config.Frameworks = {
    ESX = { enabled = GetResourceState('es_extended') == 'started' },
    QBCore = { enabled = GetResourceState('qb-core') == 'started' },
    QBox = { enabled = GetResourceState('qbx-core') == 'started' },
    VRP = { enabled = false },
}
```

**Explanation:**

* The script checks for the presence of common frameworks (`es_extended`, `qb-core`, etc.) and enables relevant functionality.
* You don’t have to manually toggle these unless you use a less common framework.

***

### 2. Society Names Mapping <a href="#id-2-society-names-mapping" id="id-2-society-names-mapping"></a>

Define friendly display names for your in-game jobs/societies.

```lua
Config.Societies = {
    ["police"] = "LSPD",
    ["ambulance"] = "EMS",
    ["mechanic"] = "Benny's Garage",
    ["taxi"] = "Downtown Cab Co.",
    -- Add others as needed
}
```

**Usage:** The script uses these names in invoices and UI elements. Make sure keys match your job names.

***

### 3. Invoice Amount Limits <a href="#id-3-invoice-amount-limits" id="id-3-invoice-amount-limits"></a>

Control the invoice value range.

```lua
Config.MinimumInvoiceAmount = 1
Config.MaximumInvoiceAmount = 999999
```

**Example:**

* Prevent invoices smaller than 1 unit or larger than 999,999 units.
* Set these based on your server economy scale.

***

### 4. Invoice Cancellation <a href="#id-4-invoice-cancellation" id="id-4-invoice-cancellation"></a>

Allow users to cancel invoices (both sent and received).

```lua
Config.AllowCancelInvoices = true
Config.AllowCancelReceivedInvoices = true
```

**Example:**

* Enabling these lets players cancel invoices they created or those sent to them, preventing disputes.

***

### 5. Proximity Check for Invoice Creation <a href="#id-5-proximity-check-for-invoice-creation" id="id-5-proximity-check-for-invoice-creation"></a>

Ensure realism by only allowing invoicing nearby players.

```lua
Config.RequireNearbyTarget = 0      -- 0 = disabled
Config.MaxDistanceForNearbyPlayers = 5.0  -- meters
```

**Example:**

* If enabled (>0), the biller must be within 5 meters to create an invoice.
* Helps prevent abuse and adds immersion.

***

### 6. Job and Grade Restrictions <a href="#id-6-job-and-grade-restrictions" id="id-6-job-and-grade-restrictions"></a>

Restrict who can create or pay society invoices.

```lua
Config.EnableGradeRestriction = true
Config.MinimumGradeLevel = 2
Config.SocietyGradePermissions = {
    viewAndCreate = 0,
    pay = 0,
    analytics = 4,
    viewSentInvoices = 0,
}
```

**Explanation:**

* Setting `viewAndCreate` to 0 means all grades in the job can invoice.
* Increasing numbers require higher job ranks (grades) for specific permissions.
* `analytics = 4` means only higher ranked members can see financial charts.

***

### 7. Notification Settings <a href="#id-7-notification-settings" id="id-7-notification-settings"></a>

Control how players get informed about billing events.

```lua
Config.ShowNotifications = true
Config.NotificationSystem = "nui"
Config.NotificationDuration = 5000  -- milliseconds
Config.NotificationColors = {
    success = "#4CAF50",
    error = "#f44336",
    info = "#2196F3",
    warning = "#ff9800",
}
```

**Example:**

* Players receive colorful pop-up messages for invoice payments, errors, etc.
* Notification colors are customizable per message type.

***

### 8. Discord Logging Configuration <a href="#id-8-discord-logging-configuration" id="id-8-discord-logging-configuration"></a>

Send billing events to Discord for audit/logging.

```lua
Config.EnableDiscordLogs = true
Config.DiscordWebhooks = {
    main = "https://discord.com/api/webhooks/your-main-webhook",
    created = "https://discord.com/api/webhooks/created-webhook",
    paid = "https://discord.com/api/webhooks/paid-webhook",
}
Config.DiscordColors = {
    created = 3447003,   -- Blue
    paid = 3066993,      -- Green
    canceled = 15158332, -- Red
}
```

**Use case:**

* Administrator can monitor billing events remotely.
* Set different webhooks for detailed logs (invoice created, paid, canceled).

***

### 9. Sound and Hotkey Settings <a href="#id-9-sound-and-hotkey-settings" id="id-9-sound-and-hotkey-settings"></a>

Enhance user experience with sounds and quick access.

```lua
Config.EnableSounds = true
Config.PlaySoundOnCreate = true
Config.PlaySoundOnPay = true
Config.EnableKeybind = true
Config.DefaultKey = "F7"
```

**Example:**

* Plays audio feedback on invoice creation and payment.
* Pressing F7 opens billing UI instantly.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://wiki.qfdevelopers.com/scripts/editor-7/configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
