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.
Signature
Section titled “Signature”vehicles.restoreState(id: number, snapshot: VehicleStateSnapshot): Promise<ActionResult>Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”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.
Example
Section titled “Example”import { vehicles, type VehicleStateSnapshot } from "nativemp";
export async function restoreAfterSpawn(vehicleId: number, saved: VehicleStateSnapshot) { return vehicles.restoreState(vehicleId, saved);}Related
Section titled “Related”vehicles.getState: capture the state before spawningvehicles.setState: apply selected fields insteadvehicles.respawn: make your vehicle clean