> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nexdevelopment.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> How to install NEX Drugs Creator on your FiveM server.

## Requirements

* FiveM server
* [`ox_lib`](https://github.com/overextended/ox_lib) (required)
* One of: [`es_extended`](https://github.com/esx-framework/esx_core), [`qb-core`](https://github.com/qbcore-framework/qb-core), or [`qbx_core`](https://github.com/Qbox-project/qbx_core)
* *(Optional)* [`ox_inventory`](https://github.com/overextended/ox_inventory) — used automatically when running
* *(Optional)* [`oxmysql`](https://github.com/overextended/oxmysql) — only when `Config.Storage = 'mysql'`

<Info>
  No database is required. The default storage backend is flat JSON files in `data/` — see [Storage backends](#storage-backends) below.
</Info>

## Steps

1. Drop the `nex_drugscreator` folder into your resources, e.g. `resources/[nex]/nex_drugscreator/`.

2. Add it to `server.cfg` **after** ox\_lib and your framework:

   ```
   ensure ox_lib
   ensure es_extended # or qb-core / qbx_core
   ensure ox_inventory # if used
   ensure nex_drugscreator
   ```

3. Grant access to the creator panel. Either add the ace permission:

   ```
   add_ace group.admin nex_drugscreator.admin allow
   ```

   …or rely on the default framework groups (`admin`, `superadmin`, `god`). A player passes if **either** check passes — see [Configuration](/nex_drugscreator/configuration).

4. Restart your server.

That's it. Run `/drugscreator` in-game to open the panel.

<Info>
  The UI ships ready to use — no build step is needed.
</Info>

## Checking it worked

From F8:

```
lua print(GetResourceState('nex_drugscreator'))
```

Should print `started`. The server console also logs a line like:

```
loaded 3 drug(s) [framework: esx | ox_inventory: yes]
```

If it warns `no framework detected`, fix your `server.cfg` load order and restart.

## Storage backends

`Config.Storage` in `config.lua` selects where drugs, zones, and runtime state are stored:

* `'json'` (default) — flat files in `data/` (`drugs.json`, `world.json`, `world_state.json`). No extra dependencies.
* `'mysql'` — oxmysql with four tables prefixed `nex_drugscreator_*` (`_drugs`, `_world`, `_meta`, `_state`).

<Info>
  With `'mysql'` you do **not** need to import any SQL manually. The tables are created automatically on first start, and any existing `data/*.json` files are imported once when the tables are empty — switching backends is lossless. A reference schema ships in `sql/nex_drugscreator.sql` if you want to review it.
</Info>

<Warning>
  If `Config.Storage = 'mysql'` but oxmysql isn't running, the resource logs an error and falls back to JSON storage.
</Warning>

## Updating

`config.lua` and `bridge/server/*.lua` are listed under `escrow_ignore`, so keep your edited copies when replacing the resource files.

If you use JSON storage, your data lives in `data/drugs.json`, `data/world.json`, and `data/world_state.json` — **keep these files** when updating. Older saves migrate automatically on start (v1 effect layouts, selling channel flags, field modes).

The resource checks the published version manifest on start and prints a console notice when a newer build is available.
