Skip to content

Events, state bags & commands ​

Server events ​

server

Server-local (AddEventHandler), never sent over the network.

Event Payload
np_drugs:server:ready none. Fired again after every restart: register hooks again
np_drugs:server:sold { source, identifier, channel, substance, item, units, count, price, total, grade, stamp, batch, coords, buyer, payees }
np_drugs:server:produced { source, identifier, line, substance, batch, units, purity, grade, site }
np_drugs:server:labStarted { source, identifier, lab, line, coords }
np_drugs:server:labStopped { source, identifier, lab, line, coords }
np_drugs:server:overdose { source, identifier, substances, batch, stamp, coords }
np_drugs:server:badBatch { batch, stamp, overdoses, reportedBy }
np_drugs:server:seized { source, target, substance, units, batch, stamp, coords }
np_drugs:server:tested { source, target, kind, result }
np_drugs:server:witness { id, kind, code, at, coords, source, identifier, title, text, note, description, rows }
np_drugs:server:rehab { source, identifier, class, event, day, court }
np_drugs:server:overdoseReported { source, identifier, target, coords }
  • sold: units is the total sold, price is per item, total the money that changed hands. buyer is { type = 'npc' | 'player', source? }. Each payees entry is { to, percent, amount, paid = 'paid' | 'queued' | 'failed' }, with a last entry for the seller marked seller = true.
  • produced: site is { id, coords }. source is nil when the cook is offline at the end of the run.
  • labStarted / labStopped: a run began / ended (finished, failed or stopped). lab is the lab id of GetLabs.
  • overdose: substances is a sorted list of ids, including a cut the user did not know about. batch is the newest dose that had one.
  • badBatch: fired once per batch, when a medic reports it or when enough overdoses happened on it. reportedBy is medic:<identifier> or nil.
  • seized: source is the officer (or the sanitation worker who handed a package in, then without a target). units is everything of that substance that was taken.
  • tested: kind is breath, swab or blood. result is { refused = true, reason }, or { bac, over, level }, { panels = { [panel id] = 'positive' | 'faint' | 'negative' } }, { bac, substances = { [id] = level } }.
  • witness: a report went out. description is { sex, features, vehicle = { name, color, plate }?, direction, street? }, rows the describe rows, text the report as one paragraph. source and identifier name the suspect and are nil for a report without one; the police never see them.
  • rehab: event is referred, enrolled, day, paused, resumed, violation (court-ordered only), completed or left.
  • overdoseReported: a medic told the police about an overdose (only with Config.Ems.reportToPolice). source and identifier are the medic's, target the patient's server id.

np_drugs listens to one event from other resources:

Event Payload
np_drugs:server:witnessCall The table Dispatch takes
lua
-- your MDT: list bad batches for medics
AddEventHandler('np_drugs:server:badBatch', function(p)
  exports.my_mdt:Alert('medic', ('Bad batch %s in circulation'):format(p.batch))
end)

-- your court script: a refused breath test goes on the record
AddEventHandler('np_drugs:server:tested', function(e)
  if e.kind == 'breath' and e.result.refused then exports.my_court:AddCharge(e.target, 'refused_breath_test') end
end)

State bags ​

Set on players by the server, replicated, read-only for everyone else.

State bag Value
Player(src).state.npd_overdose 'down', 'critical', 'recovering' or false
Player(src).state.npd_voice { filter = 'slur', strength = 0..1 } or false: the character slurs
Player(src).state.dirtyHands true for a while after digging through a bin
Player(src).state.isDowned true while down with an overdose (Config.Overdose.stateBag; false switches it off)

Client events ​

client

Event Arguments
np_drugs:voiceFilter serverId, filter | nil, strength: a voice resource that would rather muffle a slurring player itself listens to this (np_drugs' own mumble submix: Config.Effects.client.voiceSubmix)

The net events between np_drugs' client and server (np_drugs:rpc, np_drugs:nui, np_drugs:sync, …) are internal; see the NUI contract. Never trigger or listen to them from other resources.

Commands and keys ​

Command Who What
npdrugs_status Console, np_drugs.debug Bridges, siblings, the MDT status line
npdrugs_items ox / qb Console Item definitions for ox_inventory / qb-inventory, printed to the console
npdrugs_batch <substance> <purity> <units> [id] Console, np_drugs.items An imported batch (the importer for substances a server does not produce)
npdrugs_training <id> <level> Console, np_drugs.training Sets a contraband training level
drugguide Everyone The substance board
drugstatus (F7) Everyone "Right now", with the comfort setting
drugdesk Police The police terminal
k9 Police with the leash Calls or dismisses the dog
npdrugs_inspect Everyone The carry card on inventories without item actions
npdrugs_route Sanitation The board of a running route

Keys (players can rebind them in the GTA key settings): interact E, cancel X, consent E / N. Attended lab stages: A / D move the meter, W vents.