alt.Vehicle.all
Used to get
an array of all vehicles on the server..
Returns a Array<alt.Vehicle>
.
Declaration
alt.Vehicle.all: Array<alt.Vehicle>
Usage
const vehicles = alt.Vehicle.all;
Real World Example
Randomizes all vehicle colors on the server.
alt.Vehicle.all.forEach(vehicle => {
if (!vehicle || !vehicle.valid) {
return;
}
vehicle.primaryColor = Math.floor(Math.random() * 159);
vehicle.secondaryColor = Math.floor(Math.random() * 159);
});
These examples assume you have vehicle created or available on server-side