dirtLevel
Used to set
or get
the current vehicle's dirt level.
Valid values range from 0.0
to 15.0
.
Returns a number
.
Declaration
vehicle.dirtLevel: number
Usage
const dirtLevel = vehicle.dirtLevel;
// OR
vehicle.dirtLevel = 15;
Real World Example
Makes the vehicle dirty when it enters the ColShape. Makes the vehicle clean when it leaves. Could do the inverse of this and make a car wash probably.
const dirtColshape = new alt.ColshapeCircle(-1295.9208984375, 86.0835189819336, 2);
dirtColshape.makeDirty = true;
alt.on('entityEnterColshape', (colshape, entity) => {
// Check if the entity is a vehicle or not.
if (!(entity instanceof alt.Vehicle)) {
return;
}
// Check if it's the right colshape to do this.
if (!colshape.makeDirty) {
return;
}
// This is a vehicle.
entity.dirtLevel = 15;
});
alt.on('entityLeaveColshape', (colshape, entity) => {
// Check if the entity is a vehicle or not.
if (!(entity instanceof alt.Vehicle)) {
return;
}
// Check if it's the right colshape to do this.
if (!colshape.makeDirty) {
return;
}
// This is a vehicle.
entity.dirtLevel = 0;
});
Visual
Value of 0
Value of 15
These examples assume you have vehicle created or available on server-side