Events
Net events you can trigger or listen to from your own resources.
Only the events that form a stable integration surface are listed here. The rest belong to the workshop session, the tablet and the vehicle handshake, and their shape is subject to change.
Most integrations want an export rather than an event. The exports read state on demand and are the supported way to ask what a vehicle carries.
Server events
nx_mechanic:inspection
Fires on the server every time a roadworthiness inspection is recorded, whether it passed or failed. Use it to feed an MDT, a fine system or an impound.
AddEventHandler('nx_mechanic:inspection', function(plate, passed, checks)
if passed then return end
for _, check in ipairs(checks) do
if not check.ok then
print(('%s failed on %s (%s)'):format(plate, check.id, tostring(check.detail)))
end
end
end)plate— the normalised plate.passed— boolean.checks— the individual checks, each{ id, ok, detail }. The ids areengine,body,tyres,brakes,lightsandlegal. On a failedlegalcheck,detaillists what was illegal.
This is a plain server event, not a net event, so it is not sent to clients.
Client events
nx_mechanic:client:open
Opens the workshop on a vehicle for the player who receives it. Wire your own peds, zones or menu entries to it.
-- From a client script
TriggerEvent('nx_mechanic:client:open', vehicle)
-- Omit the vehicle to use the one the player is in,
-- or the nearest within 6 metres
TriggerEvent('nx_mechanic:client:open')The same gates apply as to the target option: the vehicle has to sit in a bay of a shop this player may use, and no session may already be open. Nothing happens when it cannot open.
exports.nx_mechanic:OpenWorkshop
does the same thing and tells you whether it worked.