getAttachedTo
Used to get
the vehicle that this vehicle is attached to.
Returns a Vehicle | null
.
Declaration
vehicle.getAttachedTo(): Vehicle | null;
Usage
const attachedTo = vehicle.getAttachedTo();
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 targetVehicle = trailer.getAttachedTo();
if (targetVehicle && targetVehicle.valid) {
console.log(`Attached to a vehicle.`);
}
These examples assume you have vehicle created or available on server-side