> For the complete documentation index, see [llms.txt](https://tk-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk-scripts.gitbook.io/docs/tk_drugs/common-questions-and-problems.md).

# Common questions & problems

Answers about setup, selling, jobs and labs, and fixes for common Drugs errors on a FiveM server.

## Common questions

<details>

<summary>Does it work on Qbox?</summary>

Yes. Set `Config.Framework = 'qb'` and use the ox\_inventory item tab in [Installation](/docs/tk_drugs/installation.md).

</details>

<details>

<summary>Which inventories does it work with?</summary>

Set `Config.Inventory` to `'ox'` for ox\_inventory, `'qs'` for qs-inventory, or `'default'` to use the items the framework reports for the player. An inventory that does not report its items to the framework needs the item functions in `client/frameworks/*.lua` and `server/frameworks/*.lua` changed to read it. Start the inventory before `tk_drugs`.

</details>

<details>

<summary>I have V1. Do I need to buy V2?</summary>

No. V2 is the same asset as V1: download `tk_drugs` again from the Cfx.re Portal, where it has no V2 in its name, and a `version` starting with 2 in `fxmanifest.lua` means you have it. Copy your settings into the new `config.lua` as in [Update without losing your config](/docs/tk_drugs/installation.md#update-without-losing-your-config); the V1 `config.lua` does not fit V2.

</details>

<details>

<summary>Where do players buy seeds and equipment?</summary>

At the shop peds in `Config.Shops`: the General Store sells seeds and ingredients, the Equipment Store sells equipment and boosters. Move a shop with its `coords` or delete its entry. Shops have no map blip option.

</details>

<details>

<summary>How do players plant a seed?</summary>

They use the seed item, for example `og_kush_seed`, with a `plant_pot` in the inventory. The pot is used up when the seed goes in and cannot be placed by itself. A plant can go anywhere outside `Config.DisabledAreas`.

</details>

<details>

<summary>How do I add a new drug?</summary>

Add the item to your inventory, then a recipe that gives it in `Config.EquipmentItems`. Add it to `Config.Drugs` to make it usable, and to `Config.Selling.items` or `Config.PlugApp.items` to make it sellable.

</details>

<details>

<summary>How do I add another seed or plant?</summary>

Copy an entry in `Config.Plants`, give it a new key and `item`, and set its `stages` models and `yield` items. Add the seed to your inventory and to a shop in `Config.Shops`. A booster speeds it up only if the key is in its `allowedEquipment`.

</details>

<details>

<summary>How do I use other plant models?</summary>

Start the prop pack before `tk_drugs` and write each model name in the `stages` of the plant in `Config.Plants`, in backticks like the existing ones. A stage that floats, sinks or does not show needs another z value in its `offset`. Where the leaves appear in the harvest minigame is set by `harvestLeaves`.

</details>

<details>

<summary>How do I place equipment at a fixed spot?</summary>

Add an entry to `Config.EquipmentLocations` with `coords`, `rotation` and the `configIndex` of the equipment, as in [Equipment](/docs/tk_drugs/config.md#equipment). It exists from server start without an item and players cannot pick it up. Its menu lists the recipes whose items the player carries.

</details>

<details>

<summary>How do I add more slots to a shelf or drying rack?</summary>

Add entries to `objectOffsets` of `drug_shelf`, `drying_rack` or `meth_chiller` in `Config.EquipmentItems`. Each offset is one slot and the number of offsets is the capacity, so place a new offset inside the model.

</details>

<details>

<summary>How do I change how long making drugs takes?</summary>

Plants use the `time` of each stage in `Config.Plants`, in seconds, and a `default_lamp` booster nearby makes them grow 1.5 times faster. The drying rack and meth chiller use the `time` of each entry in `items`, 30 minutes by default. Workers use `processingTime` per equipment type in `Config.WorkerSettings`.

</details>

<details>

<summary>How do I translate the script?</summary>

Copy `locales/en.lua` to a new file, change `Locales['en']` on its first line to your language code, and translate the texts. Set `Config.Locale` to that code.

</details>

<details>

<summary>How do I change the currency symbol?</summary>

Replace every `€` in the locale file that `Config.Locale` names, `locales/en.lua` by default. `value_with_currency` is the price format in the menus.

</details>

<details>

<summary>How do I use ps-dispatch or another dispatch script?</summary>

Put your dispatch export call in `AlertPolice(alertData)` in `client/main_editable.lua`. It runs for street sales, pickpocketing, Plug deliveries and drug making, and `alertData` holds `coords`, `title`, `code`, `priority`, `message` and `jobs`. `Config.Dispatch` has built-in support for `'tk'` and `'cd'` only.

</details>

<details>

<summary>How do I pay drug sales in black money or a money item?</summary>

Set `Config.Selling.moneyType`; street sales and Plug deals both pay through it. `'black_money'` works as it is: the account on ESX, the `black_money` item on QBCore and Qbox. For any other item as money, change `SoldDrugs` in `server/main_editable.lua`; shops charge the `moneyType` of each shop in `Config.Shops`:

```lua
function SoldDrugs(xPlayer, drugName, amount, price)
    AddItem(xPlayer, Config.Selling.moneyType, price)
end
```

</details>

<details>

<summary>How do I turn off street selling?</summary>

Set `Config.Selling.items = {}`. To hide the Plug app, set `plug = false` in `Config.PhoneSettings.apps`.

</details>

<details>

<summary>How do I turn off pickpocketing?</summary>

Set `interactDistance = 0` in `Config.PickPocketing`. To keep it and slow it down, raise `cooldown`.

</details>

<details>

<summary>How do I turn off the trap phone, labs and workers?</summary>

Set `listings = false` and `crew = false` in `Config.PhoneSettings.apps` to remove lab purchases and worker hiring. To remove the phone itself, leave the `trap_phone` item out of your inventory. Plants and equipment keep working without it while `Config.PlaceOnlyInsideLabs` is `false`.

</details>

<details>

<summary>How do players sell through the Plug app?</summary>

They open the trap phone, choose Plug, pick a contact and offer a drug from `Config.PlugApp.items`. Every player starts with the contacts in `contacts.initial`, which is Marco by default, and each street sale adds a contact with a `contacts.addChance` percent chance. A drug that is not in `Config.PlugApp.items` never shows there.

</details>

<details>

<summary>How do I limit an action to one job?</summary>

Return `false` from the matching function in `client/main_editable.lua`; this lets only police pick up plants:

```lua
function CanRemovePlant(data)
    return GetJobName() == 'police'
end
```

`CanPlaceEquipment(equipmentIndex)` and `CanPlacePlant(configIndex, coords, plants)` receive the config key of what is placed. `CanUseEquipment(data)` and `CanOpenPlantMenu(data)` receive the placed object. `CanUseDrug` in `server/main_editable.lua` limits who can use a drug.

</details>

<details>

<summary>Does it have exports, and how do I connect my own scripts?</summary>

It has no exports. Put your calls inside the functions of `server/main_editable.lua`: `SoldDrugs` runs for street and Plug sales, and `HarvestPlant`, `GiveRecipeItems`, `PickpocketItem`, `WaterPlant` and `FertilizePlant` run when a player harvests, finishes a recipe, pickpockets, waters or fertilises. All hooks are listed under [Editable functions](/docs/tk_drugs/config.md#editable-functions).

</details>

<details>

<summary>How do I send logs to Discord?</summary>

In `Webhook(message)` in `server/main_editable.lua`, remove the `--[[` and `]]` around the body and put your link in `webhookLink`. Shop purchases and other actions are logged through it.

</details>

<details>

<summary>Can players place equipment inside houses?</summary>

Yes, unless `Config.PlaceOnlyInsideLabs` is `true` or the spot is inside `Config.DisabledAreas`. Only workers need a drug lab. To allow it only inside houses, make `CanPlaceEquipment` in `client/main_editable.lua` return `false` unless your housing script says the player is inside.

</details>

<details>

<summary>Why can a player not buy or enter a lab?</summary>

Labs are bought in the Listings app of the trap phone for `labPrice` from the `moneyAccount` bank account, and a `price` on an entry of `Config.Labs` replaces it for that lab. The phone says `Not enough bank money` when the balance is short and `You can only own N lab(s)` at `maxOwnedLabs`. Only the owner and players granted Enter in Manage Lab can go in; everyone else sees `You don't have access to this lab`.

</details>

<details>

<summary>Can a lab be open to everyone?</summary>

No. Each lab has one owner who grants access to other players. For a place anyone can work in, use [fixed equipment](/docs/tk_drugs/config.md#equipment) from `Config.EquipmentLocations`.

</details>

<details>

<summary>How many labs can I add?</summary>

As many as you want: add an entry with `entrance` and `labType` at the end of `Config.Labs`. Recipes belong to equipment types, not to single labs. Lab number N uses routing bucket N, so keep housing buckets above the number of labs.

</details>

<details>

<summary>Can a player own more than one lab?</summary>

Yes. Set `maxOwnedLabs` in `Config.PhoneSettings`; the default is 1.

</details>

<details>

<summary>Why does the sell option not show on an NPC?</summary>

The option shows only while the player carries an item from `Config.Selling.items`, and never on players, dead NPCs, NPCs in vehicles or mission peds. With `Config.Target = 'none'` it is a key prompt instead of a target option. If it shows but the sale stops with a message, fewer police are online than `Config.Selling.minPolice`, or that NPC has already bought.

</details>

<details>

<summary>Why does the admin menu not open?</summary>

The command needs the `command.drugsadminmenu` ace, and then the `command` ace or a framework group listed in `Config.AdminGroups`. `add_ace group.admin command allow` in `server.cfg` covers both for your admin group, as in [Commands](/docs/tk_drugs/commands.md#drugsadminmenu). The server console prints `Trying to open admin menu but not an admin` when the group is not in `Config.AdminGroups` and the `command` ace is missing.

</details>

<details>

<summary>Do players lose plants, equipment or labs when I update?</summary>

No. They are stored in the database, and the script adds any new columns on start. Follow [Update without losing your config](/docs/tk_drugs/installation.md#update-without-losing-your-config).

</details>

## Common problems

### Weed or mushroom models do not load

After a player joins, the F8 console and a notification show:

```
Failed to load weed model. To fix this install the weed props. Link can be found in the README.txt file included with the script.
```

The server does not stream the free weed props or the free mushroom pack that the default config uses; the mushroom message names the mushroom props.

* Install both and start them before `tk_drugs`, as in [Drugs installation](/docs/tk_drugs/installation.md#requirements).
* Or replace the model in every cannabis `stages` entry of `Config.Plants`, and in `Config.Fields` for mushrooms, with a prop your server has. [Plebmasters](https://forge.plebmasters.de/objects) lists models.

### Props from a newer game build do not load

The F8 console prints:

```
[WARNING] Failed to load asset "MODEL_NAME"
```

The model comes from a newer GTA V game build than your server runs. [Force a newer game build](https://forum.cfx.re/t/tutorial-forcing-gamebuilds-on-fivem/4784977) on the server, for example build 3258, or change the model name in `config.lua` to one your build has.

### ox\_lib is not loaded

When a key prompt shows, the F8 console prints:

```
SCRIPT ERROR: @tk_drugs/client/main_editable.lua:161: attempt to index a nil value (global 'lib')
```

`Config.UseOxLib = true` needs ox\_lib, but its line in `fxmanifest.lua` ships commented out. `Config.NotificationType = 'ox'` needs it too, and prints the same error when a notification shows. Remove the `--` from `'@ox_lib/init.lua',` in `shared_scripts` and start `ox_lib` before `tk_drugs`. [Common problems](/docs/common-problems.md#error-attempt-to-index-a-nil-value-global-lib) has the steps without ox\_lib.

### Database tables are missing

When `tk_drugs` starts, the server console prints:

```
Table 'DATABASE.tk_drugs_equipment' doesn't exist
```

`tk_drugs.sql` was not imported, and `tk_drugs` does not create the equipment and plant tables itself. Import `tk_drugs.sql` into the database named in your `server.cfg` connection string.

### Errors name a function or table that does not exist

The console prints one of these:

```
SCRIPT ERROR: ?:-1: attempt to call a nil value (field 'GetSlotStatus')
Table 'DATABASE.tk_drugs_lamps' doesn't exist
```

The `tk_drugs` folder holds files from different versions. `tk_drugs_lamps` belongs to V1, and the current files read it only when it exists. Replace every file in the folder with the download and move your settings back, as in [Update without losing your config](/docs/tk_drugs/installation.md#update-without-losing-your-config).

### Items do nothing when used

A player uses a seed, plant pot or equipment item and nothing appears. Set `Config.DebugMode = true` and restart `tk_drugs`. The consoles then end with the reason, for example in the server console:

```
place equipment stopped: player has no item meth_oven
```

* `player has no item`: the server does not see the item through `Config.Inventory`. Set it to `'ox'`, `'qs'` or `'default'` to match your inventory.
* `not allowed to place here`: `CanPlaceEquipment` returns `false`, which `Config.PlaceOnlyInsideLabs = true` does outside a lab.
* `spot is in a disabled area`: the spot is inside `Config.DisabledAreas`.
* `lab access denied`: see the lab problem below.
* No line at all on QBCore with ox\_inventory: apply the [usable item fix](/docs/common-problems.md#items-not-working-on-qb-core-and-ox_inventory).

A seed needs a plant pot in the inventory too and shows `You need 1x Plant Pot` without one. If the consoles stay empty, a client-side anticheat or another script blocks the spawned object; see the cursor problem below.

### Item is used up but nothing appears

After placing a plant pot, seed or equipment, the item is gone and no plant or equipment shows, or the plant vanishes after the first watering. The server takes the item before it saves the placement, so a failed save or a prop that does not load leaves nothing visible.

* Props: fix the two model problems above.
* Database: the server console shows the database error. Import `tk_drugs.sql` and replace any old files.
* Anticheat: add an exception for `tk_drugs`, or remove the script that deletes spawned objects.

### Placing equipment in a house says no lab access

When a player places equipment inside a house, a notification shows:

```
You don't have access to this lab
```

Housing interiors run in routing buckets. A bucket from 1 to the number of entries in `Config.Labs` (11 by default) counts as that lab, and only its owner or players with the Place Equipment permission can place there. Start the housing script's buckets above the number of labs.

### Shop or equipment says there is no space

When a player buys from a shop or finishes a recipe, a notification shows:

```
You don't have enough space in your inventory
```

The server asks the inventory whether the player can carry each item, and the answer is no when the item is missing from the inventory's item list, even with empty pockets, or when `Config.Inventory` names another inventory.

* Add the items from `README.txt` to your inventory, as in [Installation](/docs/tk_drugs/installation.md#install).
* Set `Config.Inventory` to the inventory you run.

### Equipment says you do not have the required items

When a player uses equipment, a notification shows:

```
You don't have the required items
```

The player carries none of the equipment's recipes in full. Each recipe takes its whole `need` list of one item quality: the press needs 10 `low_quality_cocaine`, or 10 `high_quality_cocaine`, not 10 mixed.

* Compare the inventory with `need` in `Config.EquipmentItems`.
* With the items there, set `Config.Inventory` to match your inventory.

### Workers idle in the lab

The notifications say one of these:

```
One or more of your workers are waiting for ingredients
One or more of your workers have nowhere to deposit output
```

A worker takes ingredients from drug shelves in the same lab and puts the product on a shelf with room, and only equipment with recipes can have a worker.

* Put the recipe's ingredients on a drug shelf inside the lab.
* Give a shelf room for the product: its `allowedItems` must list it and `maxPerShelf` must not be reached.
* Assign the worker to the equipment through its Manage option.

### Items error in the QBCore framework file

When a player buys, places or uses an item, the server console prints:

```
SCRIPT ERROR: @tk_drugs/server/frameworks/qb.lua:143: attempt to index a nil value (field 'Items')
```

`AddItem` and `RemoveItem` in `server/frameworks/qb.lua` read `QBCore.Shared.Items`, which your framework does not have. Delete the two `TriggerClientEvent('inventory:client:ItemBox', ...)` lines in those functions. Only the qb-inventory item pop-up goes away.

### Plants disappear after a few hours

A plant dies when its water or fertiliser reaches 0, and both drop every minute, also while the server is off. Players water and fertilise their plants to fill them to 100. To make plants last longer, lower `waterDecayRate` and `fertilizerDecayRate` in `Config.PlantSettings`; see [Plants](/docs/tk_drugs/config.md#plants).

### Cursor stuck in the top right corner

The cursor jumps to a corner, or a plant or table prop drifts across the screen, when a player uses the drug menus. A client-side anticheat or another script interferes; Electron AC has an option that causes it. Find that script and add an exception for `tk_drugs`, or remove it.

### Possible cheater lines in the server console

After a street sale or a Plug deal, the server console prints:

```
[TK_DRUGS] Possible Cheater: REASON - Player Data: IDENTIFIERS
```

The server rejected the deal, and `REASON` names the failed check. `Invalid amount` and `Invalid price` mean the sale did not match `maxAmount` or `price` in `Config.Selling.items`; if players hit them without cheating, check those values.

### Cannot complete recipe warning

The server console prints:

```
[WARNING] Cannot complete recipe PLAYER_ID RECIPE_NUMBER
```

When the minigame ended, the player no longer had the recipe's `need` items or had no room for its `get` items. Make sure the items are in the inventory and have space. If the player does have them, set `Config.Inventory` to match your inventory.
