Exports ​
All exports are called as exports.np_mechanic:<name>(...) and are server-side unless marked client. np_mechanic
depends on none of the resources that call them.
- Exports answer
nil/false/0/{}until np_mechanic is ready (np_mechanic:server:ready). - Every table they return is a plain copy.
- Plates are normalised: upper case, trimmed, inner spaces kept (
'ABC 123'). - Every export that takes a plate also takes a fake plate and answers for the real, registered vehicle behind it.
Core ​
server
| Export | Returns |
|---|---|
GetVehicle(plate) |
{ plate, vin, model, owner, parts, wear, mileage, flags, tune, warranty }, or nil for a vehicle np_mechanic has never seen |
GetVehicleParts(plate) |
{ [slot] = { part, maker, tier, serial, condition, installedAt, shop } } (empty table when none) |
GetMileage(plate) |
Km driven since np_mechanic first saw the vehicle |
IsVehicleIllegal(plate) |
illegal, parts, flags: boolean, { [slot] = partId } or nil, { vinScrubbed, fakePlate, chopped }. For police inspections and MDTs |
AddServiceEntry(plate, entry) |
Writes the service book: entry = { kind, summary, details?, shop? }. Returns the entry id |
GetServiceBook(plate, limit?) |
{ { id, kind, summary, shop, details, mileage, actor, actorName, at } }, newest first |
GetShop(id) |
{ id, brand, label, coords, zones, lifts, mode, categories, services, legal, accent, blip, hours, open, enabled, job } or nil |
GetShops() |
Every enabled workshop in the GetShop shape |
GetShopAt(coords) |
The workshop whose zone contains the position, or nil |
GetPart(id) |
The catalogue entry { id, slot, maker, tier, mod, level, price, stats, bonus, wear, warranty, install, skill, illegal?, item, category } or nil |
GetSkill(src | identifier, skill) |
Mechanic level 1–5 in engine, body, paint, electronics or tyres (0 for an unknown skill) |
AddSkillXp(src | identifier, skill, amount, reason?) |
The new level, and whether it went up |
GetOrder(id) |
{ id, shop, plate, customer, customerName, mechanic, mechanicName, state, mode, items, labour, total, paid, dueAt, createdAt, updatedAt } or nil |
registerHook(name, fn) |
Hook id, or nil for an unknown name. See Hooks |
removeHook(id) |
boolean |
-- an MDT: what is wrong with this car?
local illegal, parts, flags = exports.np_mechanic:IsVehicleIllegal(plate)
if illegal then
for slot, partId in pairs(parts or {}) do print(slot, partId) end
if flags.vinScrubbed then print('VIN scrubbed') end
end
-- a garage: show the service book
for _, e in ipairs(exports.np_mechanic:GetServiceBook(plate, 10)) do
print(os.date('%Y-%m-%d', e.at), e.kind, e.summary, e.mileage)
end
-- a car wash that also checks the oil
exports.np_mechanic:AddServiceEntry(plate, { kind = 'service', summary = 'Wash and oil check', shop = 'hayes' })
Player-owned workshops ​
| Export | Returns |
|---|---|
GetBusiness(shopId) |
{ shop, owner, ownerName, balance, staff = { { identifier, name, rank, onduty } }, closed } for a player-owned workshop with an owner, else nil |
Repair and insurance ​
| Export | Returns |
|---|---|
GetInsurancePolicy(plate) |
The vehicle's Mors Mutual policy { id, label, coverage, deductible }, or nil (not insured). Order: a policy set with SetInsurancePolicy, Config.Repair.insurance.vehicles, then insurance.default for vehicles that have an owner |
SetInsurancePolicy(plate, policy) |
boolean. policy = an id of Config.Repair.insurance.policies, false = not insured, nil = back to the config / default. Stored across restarts |
-- an insurance office sells Gold cover
exports.np_mechanic:SetInsurancePolicy(plate, 'gold')
Underground ​
| Export | Returns |
|---|---|
GetHeat(src | identifier) |
The player's heat 0–100 (decays per hour, Config.Underground.heat.decayPerHour) |
GetShopHeat(shopId) |
A workshop's heat 0–100 |
AddHeat(src | identifier, amount, reason?) |
The player's new heat (negative amounts cool down). Fires heatChanged |
IsShopDark(shopId) |
dark, untilAt: the shop ran too hot and is closed until untilAt (unix seconds) |
HasKillSwitchJammer(plate) |
boolean: a kill-switch jammer is fitted (a police kill switch should ask before it cuts the engine) |
SetVehicleStolen(plate, stolen) |
boolean. Flags a vehicle stolen: its owner can then take it to a chop shop too (garages, insurance, police) |
GetRealPlate(plate) |
The registered plate behind a fake one (the same plate when it is real) |
A fake plate changes only what the entity shows. The record keeps the real plate (flags.shownPlate), and an alias
record under the fake plate points back (flags.realPlate). Inside np_mechanic every lookup resolves it, and the
exports answer for the real vehicle, so IsVehicleIllegal(fakePlate) is true. Other resources that key by the
plate text (inventory trunks and gloveboxes, vehicle keys, garages) see the displayed plate while the fake one is on.
Call GetRealPlate first if that matters.
-- a garage stores the car under its real plate
local plate = exports.np_mechanic:GetRealPlate(GetVehicleNumberPlateText(veh))
Client ​
client
| Export | Returns |
|---|---|
GetVehicleProps(veh) |
ESX-compatible props: every mod, colours, neon, xenon, extras, tyres, windows, doors, health, fuel |
SetVehicleProps(veh, props) |
boolean. Also reads qb's field names |
GetCurrentShop() |
{ id, label, brand, legal } of the workshop zone the player is in, or nil |
GetSkill(skill) |
1–5, as the server last told this client |
Item use exports ​
Items registered through the inventory get a lower-case use export (mech_scanner, mech_part_engine, …). That is
what ox_inventory's server.export = 'np_mechanic.<item>' calls. It is the inventory's business, not an API.