vehicleDamaged
Tells your gamemode that vehicle health or supported damage-manager condition changed. Game collision damage is reported
after the simulation has applied it, so your handler can inspect the result and correct it with
vehicles.setCondition or vehicles.repair.
Signature
Section titled “Signature”server.on("vehicleDamaged", ({ vehicleId, state, changeSource, observedAtSessionMs }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
vehicleId |
number |
The vehicle’s network ID. |
state |
VehicleStateSnapshot |
The current controls and supported condition. |
changeSource |
"game" | "script" | "repair" |
Damage from the game, a condition setter, or repair. |
observedAtSessionMs |
number |
When the change was observed on the shared session clock. |
Example
Section titled “Example”import { server, vehicles } from "nativemp";
server.on("vehicleDamaged", ({ vehicleId, state }) => { if ((state.condition?.health ?? 1000) < 250) void vehicles.repair(vehicleId);});Related
Section titled “Related”vehicles.getCondition: read health and damagevehicles.setCondition: correct condition fieldsvehicles.repair: repair the vehicleVehicleDamagedPayload: event payload