Skip to content

vehicles.listAll

Lists every vehicle the server knows, in every virtual world: yours, the game’s parked cars, and traffic. Each entry is the same snapshot vehicles.getById returns. countByModel and listModelsInUse count over the same list.

vehicles.listAll(): readonly VehicleSnapshot[]
vehicles.countByModel(model: number): number
vehicles.listModelsInUse(): readonly number[]
Name Type Description
model number The vehicle model ID to count.

listAll returns an immutable array of VehicleSnapshot. countByModel returns how many vehicles of that model there are. listModelsInUse returns each model in use once, in ascending order.

gamemodes/my-mode.ts
import { chat, commands, vehicles } from "nativemp";
commands.register("cars", (player) => {
const here = vehicles.listAll().filter((vehicle) => vehicle.virtualWorld === player.virtualWorld);
chat.send(`${here.length} vehicles here, ${vehicles.countByModel(411)} Infernus in total`, player);
});