Installation ​
Requirements ​
- A recent FiveM server artifact (Lua 5.4)
- oxmysql
- np_npchandler and np_prophandler, both 1.1.0+, started before np_drugs. np_npchandler spawns the K9 dog and the rehab doctors; np_prophandler draws the props in the hand, the lab equipment and the used syringes on the street
- Node 18+ to build the NUI once
- OneSync for the street sale (the server checks the ped you sell to), K9 sniffs of vehicle trunks, the car-hood
surface of the concealment bench, garbage trucks near a sanitation stop and the crash check of trunk wear. Without
it those answer
not_available(or skip the check) and everything else works.
Optional, auto-detected at start (each with a fallback, see Compatibility and Integrations):
| Kind | Resources | Without it |
|---|---|---|
| Framework | es_extended (first target), qbx_core, qb-core | Standalone: jobs from Config.StandaloneJobs, dirty cash only as an item |
| Inventory | np_inventory (first target), ox_inventory, qb-inventory, the ESX inventory | No inventory: only the body, effects, tests, rehab and dispatch |
| Staff | np_admin, np_discord | Framework admin groups and Config.Admins (see Permissions) |
| Shops | np_shops | Inventory shops for the production supplies |
| MDT | md-stempeluhr (MDT) over HTTP | The medical record stays in np_drugs |
| Dispatch | ps-dispatch, cd_dispatch, qs-dispatch, core_dispatch | A toast and a blip for police on duty |
| Other np_* siblings | np_hud, np_menu, np_phone, np_character, np_gangs | A built-in fallback for each |
| Zones | np_colshape | Distance checks instead of colshapes for enter and exit of the world points. Needed on FiveM Legacy only, GTAV Enhanced has the natives built in |
Steps ​
- Put the folder into your resources as
np_drugs. The NUI callshttps://np_drugs/rpc, item definitions callnp_drugs.useItemand other resources callexports.np_drugs, so keep the name. - Build the UI once:shThis creates
cd web && npm install && npm run buildweb/dist/index.html(every screen and HUD piece) andweb/dist/phone.html(the np_phone Vitals app).web/distis not committed. - Database: the tables (prefixed
np_drugs_) are created at start (Config.AutoCreateTables = true). To import them by hand instead, runsql/install.sql,sql/production.sqlandsql/medical.sql. - Start order in
server.cfg. The framework and the inventory are detected once, at start:cfgensure oxmysql ensure es_extended # or qbx_core / qb-core ensure np_prophandler # required, before np_drugs ensure np_npchandler # required, before np_drugs ensure np_inventory # or ox_inventory / qb-inventory ensure np_admin # optional: staff rights, settings, audit log, staff tools ensure np_hud # optional siblings, any order ensure np_menu ensure np_phone ensure np_shops ensure np_drugs ensure np_gangs # optional, after np_drugs (it may also start earlier and attaches by itself) - Items: with np_inventory they register themselves. With ox_inventory or qb-inventory run
npdrugs_items oxornpdrugs_items qbin the server console and paste the output intoox_inventory/data/items.luaorqb-core/shared/items.lua. On the ESX inventory add the items to theitemstable with the same names. See Items. - Item images: np_drugs' screens show
<Config.ImagePath><item>.png(defaultnui://np_inventory/web/images/). Put an icon per item name there (320×320 PNG); without one the screens draw a stand-in. - Jobs: map your police, medic and sanitation job names in
Config.Jobs(below). - MDT (optional): set the two convars in
server.cfg(below). - Start the server and read the start-up lines: one per bridge, one per optional sibling (
active,fallback: …,missing export <name>,off in config,not running), and how many items were registered.
Jobs ​
Config.Jobs (shared/config.lua) maps a job group to job names with a minimum grade:
Config.Jobs = {
police = { police = 0, sheriff = 0 },
medic = { ambulance = 0, ems = 0 },
sanitation = { garbage = 0 },
}
Add your job names to the group (lspd = 0). Members must be on duty where the framework knows duty.
| Group | May |
|---|---|
police |
Search, breath and swab tests, K9s, evidence, the police terminal (/drugdesk) |
medic |
Treat, tox screen, blood draw, the medical record, referrals and prescriptions |
sanitation |
Routes on the sanitation board |
Standalone servers map identifiers (or np_character ids) to jobs in Config.StandaloneJobs. Jobs are not staff:
these rights stay with Config.Jobs whether np_admin runs or not.
Permissions ​
np_drugs uses no ACE. Every staff check asks for a permission node through the np_admin lib vendored in
bridge/np_admin.lua (np_admin stays optional).
| Node | Grants |
|---|---|
np_drugs.admin |
Every node below; passes every job check of np_drugs (police, medic, sanitation) and the admin-only RPCs |
np_drugs.items |
npdrugs_batch, the staff tools give batch and give item |
np_drugs.training |
npdrugs_training, the staff tool set search training, teaching every training level |
np_drugs.body |
The staff tools body state (the numbers behind a player's body) and sober up / reset body |
np_drugs.debug |
npdrugs_status, the staff tool status |
With np_admin running, np_admin decides: grant the nodes (or np_drugs.*) to staff
groups in its permission matrix (category Drugs). The framework groups, Config.Admins and the Discord roles below
no longer count.
Without np_admin (or with Config.Integrations.np_admin = false) an admin holds every node. An admin is:
- a player in one of the framework's admin groups (
Config.AdminGroups, defaultadmin,superadmin,god: ESXgetGroup(), qb / qbxHasPermission); - a player with an identifier in
Config.Admins('license:…','discord:…','fivem:…','steam:…'); - with np_discord running, a player holding one of
Config.AdminDiscordRoles(role ids or np_discord role names; asked when the character loads and every 10 minutes); - (unless
np_admin = false) a player listed in np_admin's fallback convars (see Permissions & np_admin).
The server console may do everything.
With np_admin, its quick menu, panel and Ctrl K palette also get the staff tools Drugs: status, give batch,
give item, set search training, body state and sober up / reset body, and the settings page Drugs
(Configuration → Editable in np_admin).
MDT ​
Overdoses, tests, treatments and rehab events are mirrored to md-stempeluhr's medical module over its HTTP API. Set
the convars with set (never setr):
set np_drugs_mdt_url "https://mdt.example.com" # the /api/v1 suffix is optional
set np_drugs_mdt_key "<api key>"
Failures never stop np_drugs: they are logged once, counted and shown in the start-up status and by npdrugs_status.
Tables ​
| Table | Holds |
|---|---|
np_drugs_batches |
Every batch: substance, purity, grade, units, cut, stamp, parent, origin, tested, overdoses, bad |
np_drugs_stamps |
Stamps and their reputation |
np_drugs_body |
One body state per character |
np_drugs_secrets |
The contents of concealed items and evidence records |
np_drugs_labs, np_drugs_purchases |
Placed labs and their runs; the paper trail |
np_drugs_medical |
The medical record |
np_drugs_payouts |
Dirty cash owed to offline payees |
np_drugs_kv, np_drugs_timers, np_drugs_log, np_drugs_migrations |
Module state, timers that survive restarts, the log, applied migrations |
Check it works ​
- The console prints the bridges, one line per sibling and the number of registered items.
npdrugs_statusprints it again with the MDT line. npdrugs_batch cocaine 86 250 <your server id>in the console gives you an imported batch (one brick); use adrug_scaleto open the batch table./drugguideopens the substance board;/drugstatus(F7) shows "right now".- As police on duty,
/drugdeskopens the police terminal.
Before you open it ​
What the test harness cannot see is the game itself. Check these once on your server:
- Animations and scenarios of every timed action (
Config.Use.anim, and theanimof each action: packing, cutting open, digging, searching, injecting, CPR, the medic's kneel). - Timecycle modifiers and clipsets of the screen profiles (
Config.Effects.screens) and how strong they feel with the comfort setting; the mumble submix for slurred voices. - Prop models: lab equipment (
Config.Production.equipment), the syringe (prop_syringe_01), bin and dumpster models (Config.Trash.kinds), the concealment surfaces (Config.Conceal.surfaces.models), the K9 and doctor peds. - Coordinates: clinics and meeting places (
Config.Rehab.clinics), the police academy (Config.Search.academy), the sanitation depot and the street-bin spots (Config.Trash.job.depot,areas), the fixed lab sites and benches (Config.Production.sites.fixed,Config.Conceal.surfaces.benches), the shops, the demand areas. - Item images in your icon pack for every item on Items.
- Your jobs in
Config.Jobs, and the duty flag your framework reports. - The MDT: run
npdrugs_statusafter the first overdose; the line says whether md-stempeluhr took it. - np_hud zones: the load meter claims
top-right, so np_hud's status chips fade while someone is high. Move the meter (Config.Hud.load) and setloadClaim = falseto keep the chips. - Balance: prices, demand, the load of each substance, burst and search chances are first values.
tests/test_balance.luashows the days they lead to. - Housing: wire your housing or garage resource into
Config.Production.sites.customif labs should stand in player properties outside instances.
Known limitations ​
- One cooler pauses every packed item in its trunk (
Config.Carry.wear.coolerMode = 'trunk', the default;'items'covers a number per cooler). - Inventories other than np_inventory and ox_inventory do not report a drag between two inventories; trunk wear on them follows only what is added and removed.
- Items the inventory ships (cigarettes, burger, knife) keep the inventory's own label in every language.
- np_inventory has no
RemoveShop: a shop the inventory took over while np_shops was stopped stays there until np_drugs restarts.
Troubleshooting ​
| Symptom | Fix |
|---|---|
| Blank screens | Build the UI (web/dist missing) |
| Items cannot be used on ox / qb | Paste the output of npdrugs_items ox / qb; the definitions carry server = { export = 'np_drugs.useItem' } |
The batch table says not_available |
The inventory has no item metadata (ESX inventory). See Compatibility |
| Police cannot search or test | The job is not in Config.Jobs.police, or the officer is off duty |
| The street sale never offers | OneSync is off, or np_gangs runs (its corners replace the street sale, Config.Street.disableWith) |
| np_hud's status chips vanish while high | The load meter claims top-right (Config.Hud.loadClaim) |
| Records don't reach the MDT | Check the convars and npdrugs_status |