Skip to content

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.

server.on("vehicleStateAvailable", ({ vehicleId, state, observedAtSessionMs }) => void)
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.
gamemodes/my-mode.ts
import { server } from "nativemp";
server.on("vehicleStateAvailable", ({ vehicleId, state }) => {
server.log(`Vehicle ${vehicleId} is ready; headlights are ${state.headlights}`);
});