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.
Signature
Section titled “Signature”vehicles.listAll(): readonly VehicleSnapshot[]vehicles.countByModel(model: number): numbervehicles.listModelsInUse(): readonly number[]Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
model |
number |
The vehicle model ID to count. |
Returns
Section titled “Returns”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.
Example
Section titled “Example”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);});Related
Section titled “Related”vehicles.getById: one vehiclevehicles.listOwn: only the ones your gamemode createdVehicleSnapshot: the fields