Skip to content

vehicles.restoreState

Applies a saved VehicleStateSnapshot to an active networked vehicle. This lets your gamemode keep damage and controls when it creates a replacement. vehicles.respawn still starts the vehicle clean; call this function afterward when you want to restore saved state.

vehicles.restoreState(id: number, snapshot: VehicleStateSnapshot): Promise<ActionResult>
Name Type Description
id number The new vehicle’s network ID.
snapshot VehicleStateSnapshot The saved controls, siren and supported condition. Its original vehicleId is ignored.

A promise of an ActionResult. Unsupported parts on the new model are quietly ignored and do not cause a rejection. Invalid snapshots and unknown vehicles are rejected; a request with no answer times out.

gamemodes/my-mode.ts
import { vehicles, type VehicleStateSnapshot } from "nativemp";
export async function restoreAfterSpawn(vehicleId: number, saved: VehicleStateSnapshot) {
return vehicles.restoreState(vehicleId, saved);
}