vehicleControlChanged
Tells your gamemode that a vehicle control changed through an accepted player input, the game’s behavior, or a script
setter. The event includes the latest shared VehicleStateSnapshot. Siren changes
continue to use vehicleSirenChanged.
An engine that stops by itself, and an open door, hood or trunk that swings shut while the vehicle moves, arrive here
with changeSource "game", also while a player drives.
Signature
Section titled “Signature”server.on("vehicleControlChanged", ({ vehicleId, state, changeSource, observedAtSessionMs }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
vehicleId |
number |
The vehicle’s network ID. |
state |
VehicleStateSnapshot |
The current shared controls and supported condition. |
changeSource |
"player" | "game" | "script" |
An accepted player input, the game’s behavior, or a script setter. |
observedAtSessionMs |
number |
When the change was observed on the shared session clock. |
Example
Section titled “Example”import { server } from "nativemp";
server.on("vehicleControlChanged", ({ vehicleId, state, changeSource }) => { server.log(`${vehicleId}: engine ${state.isEngineOn ? "on" : "off"} (${changeSource})`);});Related
Section titled “Related”vehicles.getState: read current statevehicles.setState: set controls directlyvehicleControlChangeRequest: decide player inputVehicleControlChangedPayload: event payload