FiveM mechanic job: repair natives, tuning mods and job checks
Build a FiveM mechanic job: repair a vehicle with SetVehicleFixed and health natives, tune with SetVehicleModKit and SetVehicleMod, save mods, and gate actions by job.
The symptom: your mechanic fixes a car and the engine still smokes, the dents stay, a tuned part disappears after a restart, or any player can repair vehicles for free.
A mechanic job is two jobs in one: repairing (health values and natives) and tuning (vehicle mods). Both run on the client, so the part you must protect is who is allowed to trigger them.
Repairing a vehicle
One native is not enough for a clean repair. This combination does the job:
-- client
local function repairVehicle(vehicle)
SetVehicleFixed(vehicle)
SetVehicleDeformationFixed(vehicle)
SetVehicleEngineHealth(vehicle, 1000.0)
SetVehicleBodyHealth(vehicle, 1000.0)
SetVehicleUndriveable(vehicle, false)
SetVehicleEngineOn(vehicle, true, true, false)
endSetVehicleFixedrepairs the vehicle in general, including tyres.SetVehicleDeformationFixedremoves the dents the first native can leave behind.SetVehicleEngineHealthandSetVehicleBodyHealthtake a value up to1000.0. Below zero the engine is dead, so setting them back makes it start again.
Because a vehicle is a networked entity, the client doing the repair should own it. If the repair works on your own car and not on a customer's, request control first:
NetworkRequestControlOfEntity(vehicle)
local timeout = 0
while not NetworkHasControlOfEntity(vehicle) and timeout < 50 do
Wait(10)
timeout += 1
endFor partial repairs (engine only, body only), call just the matching health native. Health values also matter for other scripts, for example vehicle damage and engine health explains what each number does.
Tuning with SetVehicleMod
Mods are numbered slots. Two rules apply to all of them:
- Call
SetVehicleModKit(vehicle, 0)before any mod change. - Ask the game how many options a slot has with
GetNumVehicleMods. An index of-1is the stock part.
-- client
local function setMod(vehicle, modType, index)
SetVehicleModKit(vehicle, 0)
local count = GetNumVehicleMods(vehicle, modType)
if index >= -1 and index < count then
SetVehicleMod(vehicle, modType, index, false)
end
end
-- engine is mod type 11, brakes 12, transmission 13, suspension 15
setMod(vehicle, 11, 2)
-- turbo is a toggle, not a numbered mod
ToggleVehicleMod(vehicle, 18, true)Checking the index against GetNumVehicleMods avoids a silent failure when a vehicle has fewer options than you expect. Paint and colour use their own natives (SetVehicleColours and others), so treat them as a separate menu.
Tip: build the tuning menu from the vehicle itself, looping over the slots with
GetNumVehicleMods, rather than hardcoding the numbers. Add-on vehicles often have a different number of options.
Saving the mods
Setting a mod only changes the live entity. When the player stores the car in the garage and takes it out again, the mod is gone unless it was saved with the vehicle. Save the full set of properties after tuning and apply them when the vehicle spawns. The whole flow is in saving vehicle properties and mods.
Job-gated actions
The repair and tuning code runs on the client, so a modified client can call it for anyone. Put the rule on the server:
-- server (ox_lib)
lib.callback.register('mechanic:canRepair', function(source)
-- 1. job check: use your framework's player/job getter here
-- 2. distance check: the player must be near a vehicle or workshop
-- 3. item check and removal
local removed = exports.ox_inventory:RemoveItem(source, 'repairkit', 1)
return removed and true or false
end)-- client
lib.callback('mechanic:canRepair', false, function(ok)
if ok then repairVehicle(vehicle) end
end)The job check depends on your framework. On ESX read the job from the player object, on QBCore and QBox read it from the player data. Use your framework's getter in step 1 and compare against your mechanic job name, as covered in adding a job on ESX and adding a job on QBCore. For the callback pattern across frameworks, see server callbacks.
Other things worth gating:
- Repair kits as items, so a repair costs something and the item is removed on the server.
- Workshop zones, so tuning only opens inside a garage or at a bench.
- Paying the mechanic or the society account on the server, not from the client.
A progress bar with a cancel option makes repairs feel right. See progress bars on ESX, QBCore and ox_lib.
Checklist
| Symptom | Fix |
|---|---|
| Dents stay after repair | Add SetVehicleDeformationFixed |
| Engine still smokes | Set engine health back to 1000.0 |
| Repair works only on your own car | Request network control of the vehicle first |
SetVehicleMod does nothing |
Call SetVehicleModKit(vehicle, 0) first |
| Mod index out of range | Check GetNumVehicleMods for that slot |
| Mods vanish after restart | Save the properties with the vehicle |
| Anyone can repair | Check job, distance and item on the server |
Quick answers
Why does SetVehicleFixed not repair the body damage?
It repairs most of the vehicle but not always the visible deformation. Call SetVehicleDeformationFixed(vehicle) as well, and set the engine and body health yourself.
Why does SetVehicleMod do nothing?
You must call SetVehicleModKit(vehicle, 0) first. Without the mod kit, the game ignores the mod change.
How do I make sure only mechanics can repair?
Check the job on the server before you accept the repair, and take the repair item on the server. A client-side job check can be skipped by a modified client.

