# Config

{% code title="config.lua" %}

```
```

{% endcode %}

***

### Framework & Inventory

#### Config.Framework

Controls which framework bridge is used.

* `'auto'` – detects ESX or QBCore based on running resources.
* `'esx'` – force ESX.
* `'qbcore'` – force QBCore.

The bridge provides helpers like:

* `Framework.GetIdentifier(src)`
* `Framework.GetBlackMoney(src)`
* `Framework.RemoveBlackMoney(src, amount, reason)`
* `Framework.AddBlackMoney(src, amount, reason)`

#### Config.Inventory

Controls which inventory integration is used.

* `'auto'` – tries to detect ox\_inventory or qb-inventory.
* `'ox'` – force ox\_inventory.
* `'qb'` – force qb-inventory.

The bridge exposes:

* `Bridge.Inventory.RegisterStash(stashId, label, slots, weight, ownerIdentifier, extra, coords)`
* `Bridge.Inventory.AddItem(stashId, item, amount, metadata, slot)`
* `Bridge.Inventory.OpenStash(src, stashId, label, slots, weight)`
* `Bridge.Inventory.ClearStash(stashId)`
* `Bridge.Inventory.RemoveStash(stashId)`
* `Bridge.Inventory.CanWatchStash()` and `Bridge.Inventory.IsStashEmpty(stashId)` (optional, for auto-cleanup)

{% hint style="warning" %}
Make sure your inventory resource is started before the blackmarket.
{% endhint %}

#### Config.Target

Controls which target resource is used for drop points and NPC interaction.

* `'auto'` – detect ox\_target or qb-target.
* `'ox'` – force ox\_target.
* `'qb'` – force qb-target.

The bridge provides:

* `Bridge.Target.AddDropPoint(index, coords, heading, label, icon, distance, callback)`
* `Bridge.Target.AddNpcTarget(ped, label, icon, distance, callback)`

***

### Black money account

{% code title="black money mapping" %}

```
```

{% endcode %}

* For **ESX**, the default is usually `'black_money'`.
* For **QBCore**, point this to whichever account represents illegal money in your economy (e.g. `'black_money'`, `'markedbills'`, etc.).

The bridge uses this map to implement `Framework.GetBlackMoney` and related operations.

***

### Tablet app (lb-tablet)

{% code title="tablet config" %}

```
```

{% endcode %}

* Set `Config.LBTablet = true` to enable **lb-tablet** mode.

When enabled, the UI is loaded as a tablet app with:

* Identifier: `Config.Identifier`
* Display name: `Config.Name`
* Description: `Config.Description`
* App developer string: `Config.Developer`
* `Config.DefaultApp` decides whether it appears pinned by default in the tablet.

When `Config.LBTablet = false`, the script runs in **standalone NUI** mode and uses:

* `Config.CommandStandalone` to open (`/blackmarket` by default).

***

### Locale & notifications

{% code title="locale & notifications" %}

```
```

{% endcode %}

* `Config.Locale` selects which file from `locales/` is loaded on the client. Add your own `locales/xx.lua` to support more languages.
* `Config.NotifyType` controls which notification provider is used by `NotifyPlayer`:
  * `'esx'` – use ESX built-in notifications.
  * `'okok'` – use `okokNotify`.
  * `'brutal'` – custom notification system (example).
  * `'ox'` – use `ox_lib` notifications.
* `Config.AdminGroup` is used in ESX permissions to decide who can run admin commands. For QBCore the implementation is usually permission-based.

***

### Drop points & delivery

{% code title="drop points" %}

```
```

{% endcode %}

* Each entry defines a potential **drop location** for orders.
* `x, y, z` – coordinates.
* `w` – heading (optional).

A random drop point is chosen for each order when checking out.

#### Delivery behaviour

{% code title="delivery config" %}

```
```

{% endcode %}

* `UseExpiry` – enable or disable expiry logic.
* `ExpiryMinutes` – how long the order is valid.
  * Pre-open expiry: if the stash is never opened, it will be removed and the order marked as expired.
  * Post-open expiry: once the stash is opened, a countdown starts; after the timer, it will be cleared & removed if still active.
* `StashSlots` & `StashWeight` – capacity of the stash in your inventory system.
* `Label` – visual label (stash name).
* `SetWaypoint` – whether to automatically place a waypoint on the player’s map.
* `ShowBlip` – whether to show a temporary blip around the drop.

***

### Auto restock & stock persistence

{% code title="auto restock" %}

```
```

{% endcode %}

* `Mode = 'restart'` — Restocks once on server/resource restart.
* `Mode = 'daily'`, `'weekly'`, `'monthly'` — Starts a background loop that checks elapsed time since last restock and refills items to `maxStock`.
* `Mode = 'none'` — No automatic restock; stock only changes on purchase or admin commands.

Stock itself is stored in:

* Memory (runtime `ItemsIndex`)
* `blackmarket_stock.json` in the resource folder
* MySQL `bm_items` table (for analytics / persistence)

***

### NPC configuration

{% code title="npc config" %}

```
```

{% endcode %}

* `Enabled` – toggle NPC entirely.
* `Model` – ped model name (string).
* `Coords` – location & heading of the NPC.
* `Scenario` – optional scenario to play (idle animation).
* `Distance` – target interaction range.
* `TargetIcon` – icon shown by target resource.
* `TargetLabel` – text shown in the target menu.

Players can talk to this NPC to open the Blackmarket UI.

***

### Items configuration

Items are defined as a map under `Config.Items`:

{% code title="example items" %}

```
```

{% endcode %}

Each item supports:

* `label` – name shown in the UI.
* `price` – price per unit (in **black money**).
* `image` – file name for icon (relative to `ui/dist/images` or your chosen folder).
* `stock` – initial stock on first sync.
* `maxStock` – cap for restocks.
* `category` – one of:
  * `"pistols"`, `"smg"`, `"rifles"`, `"ammo"`, `"melee"`, `"misc"`

You may also use human-readable categories and let the script normalize them, e.g. `"pistolji"`, `"municija"`, `"puske"` are converted to internal categories.

After editing `Config.Items`, run:

{% code title="admin command" %}

```
```

{% endcode %}

to rebuild the index and sync everything to DB.
