Skip to content

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.

server.on("vehicleSnapshotsUpdated", ({ vehicles, removedVehicleIds, observedAtSessionMs }) => void)
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.
gamemodes/my-mode.ts
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}`);
}
}
});