vehicleStateAvailable
Tells your gamemode when the server has a current state snapshot for a vehicle. This happens when a vehicle becomes
active, when its first state sample arrives, and when one of your vehicles respawns clean. The SDK updates
vehicles.getState before your handler runs.
Before the first game sample, the snapshot has baseline control values and may omit supported parts or condition. The first sample refreshes it with the model’s supported parts and observed health and damage.
Signature
Section titled “Signature”server.on("vehicleStateAvailable", ({ vehicleId, state, observedAtSessionMs }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
vehicleId |
number |
The vehicle’s network ID. |
state |
VehicleStateSnapshot |
The current controls and any condition the server has observed. |
observedAtSessionMs |
number |
When the snapshot became available on the shared session clock. |
Example
Section titled “Example”import { server } from "nativemp";
server.on("vehicleStateAvailable", ({ vehicleId, state }) => { server.log(`Vehicle ${vehicleId} is ready; headlights are ${state.headlights}`);});Related
Section titled “Related”vehicles.getState: read the current snapshotVehicleStateAvailablePayload: event payloadvehicleStateRemoved: a vehicle left the shared world