Events, hooks & commands ​
Server events ​
Server-local (AddEventHandler), never sent over the network. by is a character identifier, 'npc' or 'system'.
| Event | Payload |
|---|---|
np_mechanic:server:ready |
none |
np_mechanic:server:orderCreated |
{ order } (the GetOrder shape) |
np_mechanic:server:orderStateChanged |
{ order, from, to, by }. States waiting, in_progress, ready, collected, cancelled |
np_mechanic:server:partInstalled |
{ plate, slot, part, maker, tier, illegal, serial, shop, by } |
np_mechanic:server:partRemoved |
{ plate, slot, part, by } |
np_mechanic:server:vehicleRepaired |
{ plate, kind, shop, by, amount }. kind: 'repair' (a workshop job's checklist is done, amount = parts + labour), 'quickfix' (repair kit, spare tyre, jump start; shop = nil, amount = 0), 'roadside' |
np_mechanic:server:vehicleFlagged |
{ plate, flag, value } (vinScrubbed, fakePlate, chopped, …) |
np_mechanic:server:paid |
{ source, amount, ref, method, shop, reason, payee } |
np_mechanic:server:skillLevelUp |
{ identifier, skill, level } |
np_mechanic:server:heatChanged |
{ kind, ref, value, reason }. kind 'player' (ref = identifier) or 'shop' (ref = shop id); value 0–100 after the change |
np_mechanic:server:tipOff |
{ shop, kind, heat, coords, via }. An illegal job tipped off the police; coords is the vague position they got; via 'np_drugs' or 'police' |
np_mechanic:server:vehicleChopped |
{ plate, model, shop, by, payout, parts }. A chop shop took a vehicle apart (record flagged chopped, entity deleted) |
lua
-- your own dispatch for underground tip-offs
AddEventHandler('np_mechanic:server:tipOff', function(t)
exports.my_dispatch:Send(t.coords, 'Suspicious activity at a garage', t.kind)
end)
-- a log of finished work orders
AddEventHandler('np_mechanic:server:orderStateChanged', function(e)
if e.to == 'collected' then
print(('order #%d at %s for %s: $%d'):format(e.order.id, e.order.shop, e.order.plate, e.order.total))
end
end)
Hooks ​
lua
local id = exports.np_mechanic:registerHook(name, fn)
exports.np_mechanic:removeHook(id)
Hooks run synchronously in registration order. Returning false, reason vetoes, and the refused call answers vetoed:<reason>. A hook
that errors is skipped and logged. The hooks of a resource are removed when it stops.
| Name | Payload | Return |
|---|---|---|
beforeInstall |
{ source, plate, slot, part, shop, order } before a part goes into a vehicle (mechanic, NPC crew, self-install) |
false, reason to veto |
beforeCharge |
{ source, amount, shop, reason } before any money is taken |
false, reason to veto |
beforeOrder |
{ source, shop, plate, mode, items } before a work order is created |
false, reason to refuse |
beforeChop |
{ source, plate, model, shop, owner } before a chop shop starts (asked again at the finish) |
false, reason to refuse (job cars, event vehicles) |
lua
-- no illegal parts on police cars
exports.np_mechanic:registerHook('beforeInstall', function(p)
local part = exports.np_mechanic:GetPart(p.part)
if part and part.illegal and isPoliceCar(p.plate) then return false, 'not on a police car' end
end)
State bags ​
| Bag | On | Value |
|---|---|---|
npmVeh |
Vehicle entity (set by the server only) | { vin, bonus = { [handlingField] = multiplier }, tune = { { field, scale?, add?, value } }, parts = { [slot] = partId }, nitrous? }. The client applies it as handling floats |
npmFake |
Vehicle entity | true while a fake plate is on |
Commands and keys ​
| Command / key | Who | Action |
|---|---|---|
E in a workshop zone, in a car |
Driver | Open the tuner (also the np_menu vehicle radial "Tuning") |
E / G at a lift |
Staff / customer | Raise / lower the lift · open the work order (staff) or pay & collect (customer) |
SPACE during an install |
Mechanic | The torque check |
/workorders |
Staff on duty | The order board (also in the radial) |
G at a car · E at the tow truck · H |
Mechanic on a roadside job | Fix on the spot · winch · lower the ramp |
/mechanic |
Anyone | The Mechanic app in np_mechanic's UI (with np_phone: open it on the phone) |
/jumpstart |
Anyone with mech_toolbox |
Jump start the car in front |
/underground |
Anyone in an underground shop | The counter (also a prompt at the door) |
LSHIFT (+npm_nitrous, rebindable) |
Driver | Nitrous |
/npm_compartment |
Driver | Open the hidden compartment |
/npm_inspect |
Police on duty | Inspect the vehicle in front |
/mechduty, /mechaccept |
Business staff | Clock in / out · accept a job offer |
/mechboss, /mechdeliveries |
Owners and managers · anyone | The boss tablet · the delivery board |
/mechowner <shop> <id | none> |
Staff | Give or clear a workshop owner |
Command names come from the config (Config.Workshop.board.command, Config.Phone.command, Config.Business.*Command).
Every screen shows its keys.