AI Core

ai-mechanic for developers

What ai-mechanic writes, its stash names, its usable item and its internal events.

ai-mechanic has no exports. Other scripts meet it through what it writes.

What it writes

  • Tuning. A purchase writes the vehicle's ai:props state bag (ai-core's client on the entity's owner applies it) and, for an owned vehicle, saves full props with ai-vehicles' SaveTuning. Plate, engine and body health and dirt are always taken from the entity, so a purchase never changes them.
  • Repairs save only engine and body health with ai-vehicles' SaveVehicle.
  • Health, deformation and dirt can only be changed by the client that owns the entity, so the server sends ai-mechanic:client:fix to that client.

Stashes

A job shop with a stash point registers a stash named mechanic_<shopId> (for example mechanic_lscustoms_burton) for the members of the shop's job, with the panel's slots and weight. Open it from your own script through the lib's inventory layer.

import { inventory } from "@aicore-fivem/lib/server";

// Count the repair kits in the Burton shop's stash.
const kits = inventory.getItemCount("mechanic_lscustoms_burton", "repairkit");

Usable item

The panel's Kit item (repairkit by default) is registered as usable through ai-core's inventory layer. It brings a vehicle's engine up to the panel's Engine health after value and is used up only when the work finishes.

Events

All of ai-mechanic's events are internal (its client and its server); do not call them from other scripts.

NameKindWhat it does
ai-mechanic:buyclient callback(netId, change, base): buy one tuning change at the shop the player is in.
ai-mechanic:repairclient callback(netId): repair the vehicle at a shop.
ai-mechanic:stashclient callback(shopId): open a job shop's stash.
ai-mechanic:washclient callback(netId): wash the vehicle at a car wash.
ai-mechanic:billclient callback(target, amount, reason): an on-duty mechanic bills the nearest player. Limited to 3 per 10 seconds.
ai-mechanic:client:fixserver to entity owner(netId, engine): fix the body (engine null), set the engine health, or wash (-1).

On this page