Mechanics & garages
Repairs
Your mechanic script's own fix (SetVehicleFixed) restores what GTA keeps - body, engine and fuel tank health, so a leaking tank stops leaking. RepairVehicle clears what Impact Dynamics keeps on a car: bent wheels, jammed doors, a wrecked (dead) engine and a pending slow tyre leak.
Call this from your mechanic script / repair kit after fixing the car with SetVehicleFixed (client side):
exports['ryan-impactdynamics']:RepairVehicle(vehicle)
or trigger the local event:
TriggerEvent('ryan-impactdynamics:client:repair', vehicle) -- vehicle optional: the car you sit in
Who calls it matters.
- The caller must be within 8 m of the car.
- If the caller is driving the car, its condition is cleared at once.
- If the caller is not driving (a mechanic standing next to it), the condition is only cleared once the car is back at full body and engine health - so fix it with
SetVehicleFixedfirst. - A pending slow tyre leak is kept by the driver who picked up the puncture, so it is only cancelled when the driver's client runs
RepairVehicle(or the repair event).
A full repair with SetVehicleFixed is also noticed by itself while someone drives the car (body and engine jump back to 1000).
From the server, clear the stored condition with:
exports['ryan-impactdynamics']:ClearCondition(vehicle)
This clears bent wheels, jams and the wrecked flag for everyone. It does not touch GTA's own damage, a pending slow tyre leak or an engine that is already dead - fix the car with your mechanic script too.
Garages
Bent wheels, jammed doors and a wrecked engine live in a state bag on the vehicle, so they are gone when the car is despawned. To keep them through a garage, save the condition with the vehicle and give it back after spawning it (server side):
-- storing
local condition = exports['ryan-impactdynamics']:GetCondition(vehicle) -- table or nil
-- save `condition` (e.g. json.encode) with the vehicle's other data
-- spawning
exports['ryan-impactdynamics']:SetCondition(vehicle, condition)
SetCondition validates the table, so data from an old save cannot break anything. A wrecked engine comes back into effect the next time someone gets in to drive. See Vehicle condition state for what is in it.
The fuel tank health and tyre states are GTA's own vehicle properties - save them the way your garage already saves petrolTankHealth / tyres.