getAttached
Used to get
whether or not a trailer is attached to a vehicle.
Returns a Vehicle | null
.
Declaration
vehicle.getAttached(): Vehicle | null;
Usage
const attachedVehicle = vehicle.getAttached();
Real World Example
const vehicle = new alt.Vehicle('phantom', 0, 0, 0, 0, 0, 0);
const trailer = new alt.Vehicle('trailerlogs', 0, 0, 0, 0, 0, 0);
// Hook up the vehicle to the trailer then call this function...
const attachedVehicle = vehicle.getAttached();
if (attachedVehicle && attachedVehicle.valid) {
console.log(`Trailer is attached!`);
}
These examples assume you have vehicle created or available on server-side