Skip to content

compatibility

When Config.EnableCompatible = true (default), s4-wheeldamage automatically resets its internal damage state when external mechanic scripts repair a vehicle.

This prevents conflicts where a mechanic script fixes the vehicle visually but s4-wheeldamage still tracks broken wheels or active leaks.

How it works#

Event listener#

The script registers handlers for common mechanic repair events from:

  • ESX — esx_mechanicjob:fixingvehicle, esx_mechanicjob:onFixkit, esx_mechanicjob:repairVehicle
  • QBCore — qb-mechanicjob:client:RepairVehicle, qb-mechanicjob:client:repairVehicle, qb-customs:client:repairVehicle
  • jim-mechanic — jim-mechanic:client:repairVehicle, jim-mechanic:client:RepairVehicle, jim-mechanic:client:fixVehicle
  • okokMechanicJob — okokMechanicJob:repairVehicle, okokMechanicJob:fixVehicle
  • Generic — mechanic:client:repairVehicle, mechanic:client:fixVehicle

When any of these events fire, the script calls:

lua
exports['s4-wheeldamage']:FullyRepairVehicle(vehicle)

The vehicle is resolved from the event payload (entity, vehicle, veh) or falls back to the player's current/nearby vehicle.

Native health watcher#

A background thread monitors the player's vehicle health every 750ms. If the vehicle was previously damaged (health < 800) and is now fully repaired (health > 990) without s4-wheeldamage knowing, it triggers a compatibility repair.

This catches repair methods that use native functions directly (SetVehicleFixed, SetVehicleEngineHealth, etc.) without firing events.

Cooldown: 3 seconds between auto-repairs per vehicle.

Disable compatibility#

lua
Config.EnableCompatible = false

Use this if you want s4-wheeldamage damage to persist even after external mechanic repairs, or if you handle integration manually via exports.

Add your own event#

Edit compatible.lua and add your event name to the compatibilityEvents table:

lua
local compatibilityEvents = {
    -- existing events...
    "my-custom-mechanic:repairVehicle",
}

Or trigger the export directly from your script:

lua
exports['s4-wheeldamage']:FullyRepairVehicle(vehicle)