NX CreativeNX CreativeDocs
Scriptsnx_mechanic

Installation

Resource-specific setup for nx_mechanic. Dependencies, database, admin access, and the first shop.

For server-wide prerequisites (artifacts, oxmysql, ox_lib), work through the generic install guide first. This page only covers what is specific to nx_mechanic.

Dependencies

The framework is detected at boot: ESX Legacy, QBCore or QBox. The framework resource does not have to start before nx_mechanic. Detection retries until it finds one. Pin it with Config.Framework if you run more than one.

ox_lib
Required

Callbacks, notifications, menus, progress bars, keybinds.

ox_target
Required

The interaction on a vehicle parked in a bay, and on car lifts.

oxmysql
Required

Database driver for builds, vehicle records, shops, orders and invoices.

OneSync
Required

Required. Shops, lifts and co-op sessions are networked.

ox_inventory
Optional

Optional. Parts as physical items. qb-inventory, qs-inventory, codem-inventory, core_inventory and the framework pockets are supported too.

nx-3d
Optional

Optional. Draws the screen of the tablet a mechanic holds while the panel is open. Without it the tablet prop and animation still play.

Banking and billing resources are detected too. Nothing needs to be installed for either: without one, shop takings and invoices are kept in nx_mechanic's own tables. See Adapters for the list that ships.

Database

The resource creates its own tables. On first start it reads sql/create.sql from the resource folder and runs it, and every statement in that file is safe to run again, so nothing happens on later starts.

If you would rather own your schema changes, import the file by hand before the first start:

mysql -u <user> -p <database> < sql/create.sql

The schema creates:

TableHolds
nx_mechanic_buildsThe saved build for a plate.
nx_mechanic_defaultsA department's default build per job and model.
nx_mechanic_codesShare codes.
nx_mechanic_logAudit rows for saves and services.
nx_mechanic_vehiclesPer-plate vehicle record: base handling, tuning, wear, stance, nitrous, mileage.
nx_mechanic_service_historyOne row per part replaced.
nx_mechanic_inspectionsInspection certificates.
nx_mechanic_ordersWork orders.
nx_mechanic_shopsLive shop state: label, access, owner, managers, prices, geometry.
nx_mechanic_employeesThe built-in employee roster.
nx_mechanic_ledgerEvery movement of money a commercial shop causes.
nx_mechanic_societyShop balances, when no banking resource is in use.
nx_mechanic_invoicesInvoices, when no billing resource is in use.

nx_mechanic_society and nx_mechanic_invoices stay empty when a banking or billing resource is detected: those adapters leave the money where that resource already keeps it.

Coming from nx_dutycustoms? The first start that finds nx_mechanic_builds empty copies plate builds, department defaults and share codes across. The old tables are left untouched, and nothing is copied twice.

server.cfg order

ensure oxmysql
ensure ox_lib
ensure ox_target
# ensure your framework here (es_extended, qb-core, or qbx_core)
ensure ox_inventory   # optional
ensure nx-3d          # optional
ensure nx_mechanic

Admin access

The shop creator and the developer subcommands are gated on the framework's own admin permission, not on an ACE. List the groups that count in Config.AdminGroups:

Config.AdminGroups = { 'admin', 'superadmin', 'god', 'owner' }

On ESX these are group names; on QBCore and QBox they are matched against the player's permission. A player in one of them can run /mechanic creator. The developer subcommands need the same permission and Config.DevCommands, which ships off.

Your first commercial shop

Two ways in. Either edit Config.Shops, or place one in game.

Pick the shop kind

type = 'commercial' charges the customer. access = 'self-service' lets the customer drive the panel and pay at the end; access = 'mechanic' means only staff open it and the customer approves the bill. A mechanic shop must name a job.

Add the entry

Config.Shops = {
    {
        id      = 'lscustoms',
        label   = 'Los Santos Customs',
        type    = 'commercial',
        access  = 'self-service',
        install = 'tablet',
        job     = 'mechanic',   -- staff job, and the society that receives the income
        blip    = { sprite = 72, colour = 46, scale = 0.8 },
        bays    = {
            { coords = vector3(-337.4, -136.9, 39.0), size = vector3(8.0, 12.0, 5.0), rotation = 70.0 },
        },
    },
}

A vehicle has to sit inside a bay before the workshop opens on it. size is the full width, length and height of the box, and rotation is in degrees.

Or place it in game

Run /mechanic creator as an admin. It walks you through the fields, then lets you drag each bay, lift, dyno spot and blip into place. What you place is written to nx_mechanic_shops and appears for every player straight away, with no restart and no config edit.

Set the prices

Config.Pricing decides what the shop charges. mode = 'fixed' uses the flat price per category, 'percent' charges a share of the vehicle's value, 'combined' adds both. An owner can adjust each category in game, up to Config.Pricing.markupCap times the configured price.

Decide where the money goes

Config.Business.society picks the account that receives the takings, and Config.Business.billing picks the invoice system. Both ship on 'auto', which finds whatever you already run.

Departments

A department shop is free and job-gated. Add the jobs to Config.Jobs, then give each shop a jobs list:

Config.Jobs = {
    police  = { label = 'Police', minGrade = 0, defaultsMinGrade = 3 },
    sheriff = { label = 'Sheriff', minGrade = 0, defaultsMinGrade = 3 },
}

Config.Shops = {
    {
        id      = 'mrpd',
        label   = 'Mission Row PD',
        type    = 'department',
        install = 'tablet',
        jobs    = { 'police', 'sheriff' },
        blip    = { sprite = 446, colour = 29, scale = 0.75 },
        bays    = {
            { coords = vector3(448.4, -1017.6, 28.6), size = vector3(10.0, 14.0, 5.0), rotation = 0.0 },
        },
    },
}

minGrade is who may use the workshop at all; defaultsMinGrade is who may save a build as the department's default for a model. A department blip is only drawn for someone whose job is on the list.

By default a department vehicle means class 18 (Emergency). Add models for packs that use another class, in Config.Vehicles.

Items

Parts are only items when Config.Tuning.requireItems is on, and it ships off. If you turn it on, register the item definitions listed under Parts as items.

NX Docs