> For the complete documentation index, see [llms.txt](https://rtx-dev.gitbook.io/rtxdev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rtx-dev.gitbook.io/rtxdev/drug-system.md). Agents can also search and read this documentation through its [MCP server](https://rtx-dev.gitbook.io/rtxdev/~gitbook/mcp).

# Drug System

Documentation for RTX Drug System, the FiveM Drug Script for ESX, QBCore and QBox: installation, stations, plants and custom plants, recipes, configuration, commands, exports and FAQ.

{% embed url="<https://www.youtube.com/watch?v=pgOPErXXWGg>" %}

## Purchase

[Purchase this resource](https://rtx.tebex.io/package/6967674)

**RTX Drug System** brings a real drug lab to your FiveM server. Grow, cook, boil, freeze, mix, dry, press and pack your own drugs on real equipment. Every station is a hands-on minigame. You pick the jars up with the mouse, pour them, stir, keep the heat, smash the crystal and cut the buds one by one. What is cooking, drying, growing or chilling keeps running on the server. It survives a restart, and every player around sees the same thing.

## Requirements

| Resource                                        | Required                                                       |
| ----------------------------------------------- | -------------------------------------------------------------- |
| `rtx_drug_system`                               | Yes - the script, the interface, the sounds and the animations |
| `rtx_drug_system_objects`                       | Yes - every table, pot, lamp and prop of the drug system       |
| `oxmysql`                                       | Only with `Config.Storage = "mysql"` (the default)             |
| `rtx_drug_system_labs`                          | No - two example drug lab interiors                            |
| `ox_target` / `qb-target` / `qtarget`           | No - only if you want target instead of the key prompt         |
| `ox_inventory` / `qb-inventory` / ESX inventory | One of them holds the items                                    |

## Installation

{% stepper %}
{% step %}

### Add the resources

Place `rtx_drug_system` and `rtx_drug_system_objects` into your resources folder. Add them to your `server.cfg`, after your framework and your inventory:

```
ensure rtx_drug_system_objects
ensure rtx_drug_system
```

Optional, the two example labs:

```
ensure rtx_drug_system_labs
```

{% hint style="warning" %}
Start `rtx_drug_system_objects` before `rtx_drug_system`. Keep the `data` folder and `savedata.json`. Your stations and their progress are saved there.
{% endhint %}
{% endstep %}

{% step %}

### Framework and inventory

Open `config.lua`, section 1:

```lua
Config.Framework = "esx" -- "esx", "qbcore", "qbox" or "standalone"

Config.Inventory = "default" -- "default" or "ox_inventory"

Config.Storage = "mysql" -- "mysql" or "json"
```

| Framework          | Value          |
| ------------------ | -------------- |
| ESX                | `"esx"`        |
| QBCore             | `"qbcore"`     |
| QBox               | `"qbox"`       |
| Standalone / other | `"standalone"` |

| Inventory                           | Value            |
| ----------------------------------- | ---------------- |
| ESX inventory / qb-inventory        | `"default"`      |
| ox\_inventory (QBox always uses it) | `"ox_inventory"` |

{% hint style="info" %}
In standalone mode fill in the item and money functions in `server/other.lua`. Use the ESX and QBCore parts in the same file as reference.
{% endhint %}
{% endstep %}

{% step %}

### Items

The `items` folder has every item of the system:

| File                     | For                                                      |
| ------------------------ | -------------------------------------------------------- |
| `items/esx.sql`          | ESX - import it into your database                       |
| `items/qbcore.lua`       | QBCore - paste into `qb-core/shared/items.lua`           |
| `items/ox_inventory.lua` | ox\_inventory - paste into `ox_inventory/data/items.lua` |

The item pictures are in `html/img/items`. Copy them into your inventory.
{% endstep %}

{% step %}

### Database

With `Config.Storage = "mysql"` import `sql.sql` once.

With `Config.Storage = "json"` nothing is imported. The stations are saved in `data/equipment.json`.

{% hint style="info" %}
Servers that already ran the old version keep their table. Every placed station and its progress stays.
{% endhint %}
{% endstep %}

{% step %}

### Admins

Admins can pick up any station, place fixed stations and use the test mode. Give them the ACE in `server.cfg`:

```
add_ace group.admin drugsystem.admin allow
```

ESX groups, QBCore permissions, jobs and single players by identifier can be allowed too. See [Permissions](#permissions).
{% endstep %}
{% endstepper %}

## The Stations

Every station is an item. Use the item and you place the station in the world. Hold `G` next to it and you pick it up again. The item comes back.

| #  | Station           | Item              | What it does                                  |
| -- | ----------------- | ----------------- | --------------------------------------------- |
| 1  | Plant Pot         | `rtxpot`          | Grow weed, coca and your own plants           |
| 2  | Packing Table     | `rtxpackingtable` | Bags of weed, cocaine and meth, and joints    |
| 3  | Cooking Table     | `rtxcookingtable` | Cook liquid meth                              |
| 4  | Cauldron          | `rtxcauldron`     | Boil coca leaves into cocaine                 |
| 5  | Brick Press       | `rtxpress`        | Press weed and cocaine bricks                 |
| 6  | Meth Chiller      | `rtxmethchiller`  | Freeze liquid meth and smash it into crystals |
| 7  | Mixing Table      | `rtxmixingtable`  | Cut cocaine and meth with sugar               |
| 8  | UV Tripod Lamp    | `rtxlamp1`        | Plants near it grow faster                    |
| 9  | UV Tripod Lamp XL | `rtxlamp2`        | Plants near it grow faster                    |
| 10 | UV Frame Lamp     | `rtxframelamp`    | Plants near it grow faster                    |
| 11 | Drying Stand      | `rtxdryingstand`  | Dry the weed buds                             |

### Using a station

Walk up to a station and press `E`. The menu shows every recipe of the station, what it needs, what you have and how long it takes. Pick a recipe and an amount and start.

The minigames are played with the mouse. Click the object that glows to pick it up. Move the mouse and click again to put it down or use it. `BACKSPACE` cancels.

{% hint style="info" %}
The mouse works even when another script holds the cursor.
{% endhint %}

* A station is used by one player at a time
* A player who leaves, dies, crashes or walks away frees the station on his own in a few seconds
* With `Config.RefundOnCancel = true` the items he put in come back
* The cooking table, the cauldron and the mixer show their countdown on their own screen

### Packing Table

1. Take an empty bag
2. Take the product and put it in the bag
3. Put the full bag on the pile

Up to 9 bags in one go. Weed, cocaine, meth and joints.

### Cooking Table

1. Pour the ammonia into the beaker
2. Crush the pills into it
3. Add the red phosphorus and the iodine
4. Stir the mixture
5. Take the flask and pour the mixture into it
6. Put the flask back over the burner
7. **Keep the heat** - press the heat button to keep the temperature in the green zone

```lua
heat = {target = 220, zone = 10, time = 20}, -- Target temperature, +- zone, seconds to hold it
```

When the heat is held, the table cooks on its own. Come back when the countdown ends and take the liquid meth.

### Cauldron

1. Pour the fuel into the cauldron
2. Throw the coca leaves in, one by one
3. Light up the cauldron

The cauldron boils on its own. Take the cocaine when it is done.

### Brick Press

1. The product is put into the form
2. Pull the lever and press the brick

Weed and cocaine bricks.

### Meth Chiller

The chiller has 12 tray slots. Every slot shows if it is empty, chilling or ready.

**Put a tray in:**

1. Pour the liquid meth into the tray
2. Open the chiller door
3. Slide the tray into its slot

**Take a tray out when it has set:**

1. Open the door and take the tray out
2. Smash the frozen meth with the hammer
3. Collect the crystals

```lua
Config.Chiller = {
	slots = 12, -- How many trays can be used (1 - 12)
	duration = 30, -- How long one tray chills, in seconds
	input = {item = "methliquid", amount = 1}, -- What one tray needs
	output = {item = "methbud", amount = 6}, -- What one tray gives
	hits = 6 -- How many hammer hits it takes to break the crystal
}
```

### Mixing Table

1. Drop the product into the mixer
2. Close the lid and start the mixer

The mixer works on its own. Up to 8 in one go.

### Drying Stand

Hang the buds up. Take them down when they are dry. Up to 8 in one go.

## Plants

A plant grows through 4 stages:

1. Fill the pot with soil
2. Put the seed into the hole and cover it with soil
3. Water the plant and spray the fertilizer
4. Cut the buds off with the scissors when it is fully grown

The watering can, the spray and the soil bag follow your mouse. Point at the pot and hold it there. The progress bar fills while you pour.

When you stand at a pot, a small card shows the plant, its water, fertilizer and growth.

```lua
Config.PlantInfo = true
```

### Growing

```lua
Config.Plants = {
	stages = {[0] = 20, [1] = 40, [2] = 50, [3] = 50}, -- Seconds of each stage
	consumption = {
		water = {every = 2, amount = 1},
		fertilizer = {every = 2, amount = 1}
	},
	requirefertilizer = true, -- false = water is enough
	growoffline = false, -- true = plants also grow while the server is off
	wither = {
		enabled = false, -- true = a plant left without water or fertilizer too long dies
		after = 600
	}
}
```

* A plant only grows while it has water and fertilizer
* Without them it stops. With `wither` on it dies and has to be cleared
* What every step needs is in `Config.Plants.items` - soil bag, watering can, fertilizer, scissors

### UV lamps

A lamp close to the pot speeds the plant up. The closer the lamp, the faster it grows.

```lua
light = {
	{distance = 0.25, multiplier = 2.0},
	{distance = 0.5, multiplier = 1.75},
	{distance = 1.0, multiplier = 1.50},
	{distance = 1.5, multiplier = 1.25}
}
```

```lua
Config.Lamps = {
	light = true, -- The lamps really light the plants under them
	color = {r = 214, g = 120, b = 255},
	brightness = 4.0,
	distance = 25.0
}
```

### Your own plants

Every plant is in `Config.Plants.types`. Copy a plant, give it a new key, its own seed and harvest item.

```lua
skunk = {
	enabled = true,
	icon = "fa-cannabis",
	color = "#9c27b0",
	seed = "skunkseed",
	harvest = {item = "skunkbud", amount = {8, 12}}, -- A number or {min, max}
	seeds = {chance = 35, amount = {1, 2}}, -- Chance to get seeds back
	speed = 0.8, -- Growth speed
	thirst = 1.3, -- Water use
	hunger = 1.0, -- Fertilizer use
	visual = "weed"
}
```

| `visual` | Looks like       |
| -------- | ---------------- |
| `"weed"` | The weed models  |
| `"coca"` | The coca model   |
| `{...}`  | Your own objects |

**Your own objects:**

```lua
visual = {
	stages = {"small_model", "medium_model", "big_model"}, -- A model per stage
	-- or
	model = "my_plant_model", -- One model that grows in size
	ranges = {{0.0, 0.4}, {0.4, 0.6}, {0.6, 1.0}}, -- Size range of each stage
	harvestprop = "my_bud_model", -- What is cut off
	harvestpositions = "weed", -- "weed", "coca" or your own list
	seed = "my_seed_model",
	offset = 0.39 -- Height of the plant above the bottom of the pot
}
```

The full example is the `wildweed` plant in `config.lua`. Add the seed and harvest items to your inventory, and a `plant_<key>` line to the language file (or set `label`).

## Recipes

Every station has its own list in `Config.Recipes`. The menu shows them in this order.

```lua
{
	id = "weedbag", -- Unique name
	enabled = true, -- false hides it
	label = nil, -- Name in the menu, nil = the name of the output item
	image = nil, -- Picture, nil = html/img/items/<output item>.webp
	max = 9, -- How many in one go
	duration = 20, -- How long the station works afterwards, in seconds
	visual = "weedbag", -- Which objects the minigame uses
	ingredients = {{item = "weedbud", amount = 1}, {item = "emptybag", amount = 1}},
	output = {item = "weedbag", amount = 1}
}
```

| Station  | Max in one go | `visual` / `prop`                                               |
| -------- | ------------- | --------------------------------------------------------------- |
| Packing  | 9             | `"weedbag"`, `"cocabag"`, `"methbag"`, `"joint"`                |
| Cooking  | 1             | `"meth"`                                                        |
| Cauldron | 1             | `"cocaine"`                                                     |
| Press    | 1             | `"cocabrick"`, `"weedbrick"`                                    |
| Mixing   | 8             | `prop`: `"cocabud"`, `"methbud"`, `"weedbud"` or your own model |
| Drying   | 8             | `prop`: what hangs on the stand                                 |

Add as many recipes as you want. The ingredients, the output and the time are up to you.

## Placing Equipment

Use the item of a station to place it.

```lua
Config.Placement = {
	mode = "gizmo", -- "gizmo" or "classic"
	maxdistance = 6.0, -- How far from the player, in metres
	spacing = 0.6, -- Smallest distance between two stations (lamps ignore it)
	onlyinterior = false -- true = only inside an interior (MLO, shell, ...)
}
```

### Gizmo

A free camera opens with a gizmo on the station.

| Key               | Action                                             |
| ----------------- | -------------------------------------------------- |
| `LMB`             | Drag the arrows to move it, or the ring to turn it |
| `RMB` (hold)      | Look around and fly                                |
| `W` `A` `S` `D`   | Fly                                                |
| `SPACE` / `SHIFT` | Up / down                                          |
| **Move / Rotate** | Switch what the gizmo does                         |
| **World / Local** | The axis of the gizmo                              |
| **On the ground** | Drops the station onto the ground                  |
| **Place**         | Places the station                                 |

Fly speed, look speed and snapping are sliders right in the panel.

### Classic

The station sits where you look. Arrows move it, `Q` / `E` turn it, `ENTER` places it, `BACKSPACE` cancels.

### Where it can be placed

```lua
blacklist = {
	enabled = false, -- true = no equipment in these zones
	zones = {
		{coords = vector3(230.0105, -799.7448, 30.5629), radius = 100.0}
	}
},
whitelist = {
	enabled = false, -- true = equipment only inside these zones
	zones = {
		{coords = vector3(1005.85, -3200.30, -38.99), radius = 60.0}
	}
}
```

```lua
Config.RoutingBuckets = false -- true = equipment in a routing bucket (instance, house) only exists in that bucket
```

### Limits and access

```lua
Config.Equipment = {
	[1] = {item = "rtxpot", limit = 0}, -- limit = how many one player can have placed. 0 = no limit
	...
}

Config.Access = "everyone" -- "everyone" or "owner"
```

### Picking up

```lua
Config.Pickup = {
	enabled = true, -- Hold G next to your own station
	busy = false, -- false = a working station can not be picked up
	plants = true, -- true = a pot with a growing plant can be picked up, the plant is lost
	command = "removeequipment"
}

Config.PickupHold = 1500 -- How long G is held, in milliseconds
```

Players pick up only their own stations. Admins can remove any station with `/removeequipment`.

## Fixed Stations & Labs

Fixed stations are always there. They are open to everyone and can not be picked up. Their progress is saved in `savedata.json`.

There are two ways to add them:

* **`/drugplace`** - admins place a station in game, see [Commands](#commands)
* **`Config.DrugObjects`** - for those who like to write them by hand

```lua
Config.DrugObjects = {
	[11] = {objecttype = 2, objectcoords = vector3(-1153.87, -2331.28, -1.24), objectrotation = vector3(0.0, 0.0, 0.56)},
	...
}
```

{% hint style="warning" %}
Keep the numbers in `[ ]` unique. Never reuse an old one.
{% endhint %}

### Example labs

`rtx_drug_system_labs` has two empty interiors. `Config.DrugObjects` fills them with stations out of the box.

* -1158.54272, -2315.69922, -1.97996569
* -1164.99609, -2328.88843, -0.5739994

## Dealers

NPCs that buy the finished product. The player only sees what he really has on him. Pick an item, set the amount (or **All**) and sell.

```lua
Config.Dealers = {
	enabled = true,
	account = "money", -- "money", "bank" or "black_money" (ESX) / "cash", "bank", "crypto" (QBCore)
	distance = 2.0,
	pricevariation = 0, -- Every restart each price moves by up to this many percent
	policealert = {
		enabled = false, -- true = a sale can alert the police
		chance = 15
	},
	blip = false,
	locations = {
		{
			pedmodel = "csb_grove_str_dlr",
			coords = vector3(-70.22, -1206.34, 26.9),
			heading = 304.0,
			items = {
				{item = "methbag", price = 400, icon = "fa-pills"},
				...
			}
		}
	}
}
```

Default dealers:

* -70.22, -1206.34, 26.9
* -131.91, -1621.27, 31.51

The police alert itself is in `PoliceAlertRTX` in `server/other.lua`. Put your dispatch in there.

## Shops

NPCs that sell the equipment, the chemicals and the seeds.

```lua
Config.Shops = {
	enabled = true,
	account = "money", -- "money" or "bank"
	distance = 2.0,
	maxamount = 50, -- Most items one purchase can buy
	blip = false,
	locations = {
		{
			label = "EquipTech",
			pedmodel = "ig_cletus",
			coords = vector3(-41.15, -226.55, 44.79),
			heading = 77.0,
			items = {
				{item = "rtxpackingtable", price = 850},
				...
			}
		}
	}
}
```

| Shop              | Coords                  | Sells                        |
| ----------------- | ----------------------- | ---------------------------- |
| EquipTech         | -41.15, -226.55, 44.79  | Every station and lamp       |
| Urban Chem Co.    | 714.49, -717.04, 25.12  | Chemicals, tools, soil, bags |
| Underground Seeds | -134.7, -1448.98, 32.46 | Weed and coca seeds          |

## Drug Effects

With `Config.DrugEffects` enabled these items can be used:

| Item        | Effect        |
| ----------- | ------------- |
| `weedjoint` | Smoke a joint |
| `cocabag`   | Sniff cocaine |
| `methbag`   | Take meth     |

```lua
weedjoint = {effect = "weed", duration = 30, health = 10, armor = 0, stamina = false, speed = 1.0},
```

| Value      | What it does                                     |
| ---------- | ------------------------------------------------ |
| `effect`   | `"weed"`, `"cocaine"`, `"meth"` or your own name |
| `duration` | How long it lasts, in seconds                    |
| `health`   | Health added when it kicks in                    |
| `armor`    | Armor added when it kicks in                     |
| `stamina`  | `true` = infinite stamina for the duration       |
| `speed`    | Run speed, 1.0 = normal, 1.49 at most            |

The look of the effects is in `DrugEffectRTX` in `client/other.lua`, open source. Add your own drugs there.

## Police

```lua
Config.Police = {
	job = "police",
	equipment = 0, -- Officers online to use any station. 0 = no check
	sell = 0, -- Officers online to sell to a dealer
	buy = 0 -- Officers online to buy in the shops
}
```

Add `"police"` to `Config.Admins.jobs` and the police can take labs down with `/removeequipment`.

## Interface & Interaction

```lua
Config.Language = "English"
Config.MenuStyle = "modern" -- "modern" or "classic"
Config.InterfaceColor = "#ff66ff" -- Accent colour of the whole interface
Config.Currency = "$"
Config.InteractionSystem = 1
Config.PromptPosition = "right" -- "right", "center" or "left"
Config.Notifications = "rtx"
Config.HideHud = true
```

### Two menu styles

| `MenuStyle` | Look                                  |
| ----------- | ------------------------------------- |
| `"modern"`  | The new RTX interface                 |
| `"classic"` | The menus of the original Drug System |

The style covers every menu - crafting, plant, chiller, dealer, shop and placement.

### Prompt

| `InteractionSystem` | Prompt                                         |
| ------------------- | ---------------------------------------------- |
| `1`                 | RTX prompt, matching the rest of the interface |
| `2`                 | 3D text                                        |
| `3`                 | GTA Online style help                          |
| `4`                 | Floating help text above the station           |

`Config.Notifications = "rtx"` uses the built-in notifications. Anything else calls `Notify()` in `client/other.lua`.

What `Config.HideHud` hides is in `HideHudRTX` / `ShowHudRTX` in `client/other.lua`. Put your own HUD in there.

### Screens

```lua
Config.Screens = {
	enabled = true, -- The cooking table, the cauldron and the mixer show their countdown on their own screen
	distance = 10.0
}
```

A screen is drawn only while the station works and a player is close.

### Keys

```lua
Config.Keys = {
	interact = "E", -- Use a station, talk to a dealer, open a shop
	pickup = "G" -- Pick your own station up (hold it)
}
```

{% hint style="info" %}
These are key mappings. Every player can rebind them in **Settings > Key Bindings > FiveM**.
{% endhint %}

### Target

```lua
Config.Target = true
Config.Targettype = "oxtarget" -- "oxtarget", "qbtarget" or "qtarget"
```

The stations, the dealers and the shops get target options instead of the `E` prompt. The registering is in `client/other.lua`, open source.

## Sounds

```lua
Config.Sounds = {
	enabled = true,
	volume = 0.6,
	distance = 15.0, -- Players closer than this hear a station working
	interface = true
}
```

Pouring, the burner, the bubbling cauldron, the mixer, the press, the hammer, the scissors and more. A working station is heard by every player close to it. The files are in `html/sounds`, replace them freely.

## Synchronization

The server owns every station. A player who opens a station locks it for himself. The lock is kept alive while he works. It drops the moment he leaves, dies, disconnects or crashes, so a table can never stay blocked.

Timers are stored as real end times. A countdown is always right, also after a restart.

Every minigame is checked on the server. A minigame finished faster than possible is cancelled.

No station is a networked entity. Everything is created locally on each player's screen. The script runs on servers with `sv_entityLockdown "strict"` without any extra setup.

## Player Checks

Nobody can use a station while dead or down, cuffed, in a vehicle, in the pause menu or with the inventory open. A player who dies in a minigame leaves it, and his items come back.

How death and cuffs are detected is in `IsPlayerDeadRTX()` and `AllowedInteraction()` in `client/other.lua`. Your ambulance script can also trigger `rtx_drug_system:client:playerDied`.

## Commands

| Command             | Who               | What it does                           |
| ------------------- | ----------------- | -------------------------------------- |
| `/removeequipment`  | Owners and admins | Pick up the station you stand at       |
| `/drugplace <1-11>` | Admins            | Place a fixed station without its item |
| `/drugdebug`        | Admins            | Test mode on / off                     |

`/drugplace` takes the number or the name of the station:

```
/drugplace 3
/drugplace cooking
```

```lua
Config.Pickup.command = "removeequipment"
Config.Admins.placecommand = "drugplace"
Config.Admins.debugcommand = "drugdebug"
```

Rename any of them, or set it to `""` and it is never registered.

### Test mode

`/drugdebug` turns the test mode on for you. Every station works without ingredients, seeds, soil, water or tools. Nothing is taken. Made for building and testing labs.

## Permissions

```lua
Config.Admins = {
	ace = "drugsystem.admin",
	commandace = true, -- Players allowed every command count as admins too
	groups = {"admin", "superadmin", "god"},
	jobs = {},
	identifiers = {}
}
```

A player is an admin if **any** of these is true:

* he has the ACE `drugsystem.admin`
* `commandace = true` and he has `add_ace group.admin command allow`
* his ESX group / QBCore permission is in `groups`
* his job is in `jobs`
* one of his identifiers is in `identifiers`

Identifiers can be the ESX identifier, the QBCore citizenid, `license:`, `discord:` - or just the part after the colon.

## Language

Every line of text is in the `language` folder, open source. 18 languages are included:

English, German, Spanish, French, Czech, Polish, Portuguese, Italian, Russian, Turkish, Korean, Dutch, Chinese, Romanian, Hungarian, Thai, Japanese, Arabic

```lua
Config.Language = "German"
```

Anything missing falls back to English. Single item names can be changed in `Config.ItemLabels`.

## Open-Source Files

This product is protected by the Escrow System. You can still configure almost everything:

| File               | What is in it                                                                     |
| ------------------ | --------------------------------------------------------------------------------- |
| `config.lua`       | Everything configurable, fully commented                                          |
| `language/*.lua`   | Every text, in 18 languages                                                       |
| `client/other.lua` | Notifications, prompts, target, death check, hiding your HUD, drug effects, hooks |
| `server/other.lua` | Framework, money, items, jobs, admin checks, police alerts, Discord logs, hooks   |
| `html`             | The interface and the sounds                                                      |
| `items`            | Item lists for ESX, QBCore and ox\_inventory                                      |

### Your own rules

`CanUseStationRTX` in `server/other.lua` is called before a station is used. Return `false` there to block it for your own reasons - jobs, levels, cooldowns.

### Discord logs

Switched on in `server/other.lua`, in `LogsRTX`. Every log can be turned on or off: placed, picked up, crafted, harvested, sold, bought. The webhook lives there too. Never put it in `config.lua` - that file is sent to every player.

## Exports & Events

### Client exports

```lua
exports.rtx_drug_system:IsBusy() -- true while the player uses a station, a menu or places one
exports.rtx_drug_system:IsInMinigame() -- true while a minigame runs
exports.rtx_drug_system:GetNearestStation() -- id of the station the player stands at, or nil
```

### Server exports

```lua
exports.rtx_drug_system:GetStation(id)
exports.rtx_drug_system:GetStations()
exports.rtx_drug_system:CreateStation(type, coords, rotation, bucket, owner)
exports.rtx_drug_system:RemoveStation(id)
exports.rtx_drug_system:IsPlayerBusy(source)
```

### Server events

```lua
AddEventHandler("rtx_drug_system:server:placed", function(source, station, type, coords) end)
AddEventHandler("rtx_drug_system:server:pickedup", function(source, station, type, owner) end)
AddEventHandler("rtx_drug_system:server:crafted", function(source, station, recipe, item, count) end)
AddEventHandler("rtx_drug_system:server:harvested", function(source, station, plant, item, count) end)
AddEventHandler("rtx_drug_system:server:sold", function(source, item, count, money) end)
AddEventHandler("rtx_drug_system:server:bought", function(source, item, count, money) end)
AddEventHandler("rtx_drug_system:server:policeAlert", function(source, coords, item) end)
```

### Client events

```lua
AddEventHandler("rtx_drug_system:client:opened", function(station, type) end)
AddEventHandler("rtx_drug_system:client:closed", function(station, type) end)
AddEventHandler("rtx_drug_system:client:hideHud", function() end)
AddEventHandler("rtx_drug_system:client:showHud", function() end)
TriggerEvent("rtx_drug_system:client:playerDied") -- from your ambulance script
```

## Anticheat

Every station and prop is created locally on each player's screen and is never networked. During a minigame a script camera is used. If your anticheat reports scripted cameras, check `exports.rtx_drug_system:IsBusy()` before it acts.

## Updating from the Old Version

{% stepper %}
{% step %}

### Back up and replace

Back up your `config.lua`, `savedata.json` and `data` folder. Then replace the whole `rtx_drug_system` folder.
{% endstep %}

{% step %}

### Configure your settings

Set your settings again in the new `config.lua`. The old config does not fit the new version.
{% endstep %}

{% step %}

### Your stations stay

Your database table stays as it is. Every placed station and its progress stays. Put your `savedata.json` back.
{% endstep %}

{% step %}

### Do not run both versions

Do not run the new version next to the old one.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>The stations do not show up</summary>

`rtx_drug_system_objects` is not started, or it starts after `rtx_drug_system`. Put `ensure rtx_drug_system_objects` first and restart the server.

</details>

<details>

<summary>Nothing is saved after a restart</summary>

With `Config.Storage = "mysql"` import `sql.sql` and make sure `oxmysql` runs. Or switch to `Config.Storage = "json"`.

</details>

<details>

<summary>A station says it is busy</summary>

Somebody else uses it. If that player crashed, the station is free again on its own after `Config.Lock.timeout` seconds.

</details>

<details>

<summary>I can not place a station</summary>

Check `Config.Placement` - the distance, the spacing, `onlyinterior` and the zones. Check the `limit` of the station in `Config.Equipment`.

</details>

<details>

<summary>I can not pick a station up</summary>

Only your own stations can be picked up. A working station can not be picked up with `Config.Pickup.busy = false`. Fixed stations are removed only by admins with `/removeequipment`.

</details>

<details>

<summary>My plant does not grow</summary>

It needs water and fertilizer. Look at the plant card or the plant menu. A UV lamp close to the pot makes it grow faster.

</details>

<details>

<summary>Nobody pays on standalone</summary>

Standalone has no money and item system. Fill in the functions in `server/other.lua`.

</details>

<details>

<summary>Target does not work</summary>

`Config.Target = true` needs the target resource running. Check the name in `Config.TargetSystemsNames`.

</details>

<details>

<summary>A dead player stays in his minigame</summary>

Your ambulance script uses a death state the script does not know yet. Add it to `IsPlayerDeadRTX()` in `client/other.lua`, or trigger `rtx_drug_system:client:playerDied`.

</details>

## Support

If you need help with installation, configuration or have any questions regarding this resource, feel free to contact us on our Discord server:

[Join our Discord](https://discord.gg/rtxdev)
