vehicleSnapshotsUpdated
Tells your gamemode which vehicles changed since the last update and which are gone. A change of who sits in a vehicle,
which player’s game runs it, its virtual world, interior, model, look or wreck status arrives at once. Motion, controls
and condition arrive at most 5 times a second per vehicle. vehicles.getById
already returns the new snapshots when your handler runs.
Signature
Section titled “Signature”server.on("vehicleSnapshotsUpdated", ({ vehicles, removedVehicleIds, observedAtSessionMs }) => void)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
vehicles |
readonly VehicleSnapshot[] |
The new or changed vehicles. |
removedVehicleIds |
readonly number[] |
Vehicles that are gone. |
observedAtSessionMs |
number |
When the server saw the changes, on the shared session clock. |
Example
Section titled “Example”import { server } from "nativemp";
const speedLimit = 50; // m/s
server.on("vehicleSnapshotsUpdated", ({ vehicles }) => { for (const vehicle of vehicles) { if (vehicle.driverPlayerId !== null && Math.hypot(...vehicle.velocity) > speedLimit) { server.log(`Player ${vehicle.driverPlayerId} is speeding in vehicle ${vehicle.vehicleId}`); } }});Related
Section titled “Related”vehicles.getById: read one vehiclevehicles.listAll: every vehicleVehicleSnapshotsUpdatedPayload: event payload