VehicleClient

attachVehicleOnToTrailer

ATTACH_VEHICLE_ON_TO_TRAILER0x16B5E274BDE402F8

The GTA V native ATTACH_VEHICLE_ON_TO_TRAILER of the VEHICLE namespace, as LS:MP client scripts call it: the global function attachVehicleOnToTrailer, in JavaScript and in Lua.

SignatureJavaScript
attachVehicleOnToTrailer(
  vehicle: Vehicle,
  trailer: Vehicle,
  offsetX: number,
  offsetY: number,
  offsetZ: number,
  coordsX: number,
  coordsY: number,
  coordsZ: number,
  rotationX: number,
  rotationY: number,
  rotationZ: number,
  disableCollisions: number
): void
SignatureLua
attachVehicleOnToTrailer(
  vehicle: Vehicle,
  trailer: Vehicle,
  offsetX: number,
  offsetY: number,
  offsetZ: number,
  coordsX: number,
  coordsY: number,
  coordsZ: number,
  rotationX: number,
  rotationY: number,
  rotationZ: number,
  disableCollisions: number
)

Usage

JavaScript
attachVehicleOnToTrailer(
  vehicle, trailer, offsetX, offsetY, offsetZ, coordsX, coordsY, coordsZ, rotationX, rotationY,
  rotationZ, disableCollisions
);
Lua
attachVehicleOnToTrailer(
    vehicle, trailer, offsetX, offsetY, offsetZ, coordsX, coordsY, coordsZ, rotationX,
    rotationY, rotationZ, disableCollisions
)

Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.

JavaScript · with vectors
attachVehicleOnToTrailer(vehicle, trailer, offset, coords, rotation, disableCollisions);
Lua · with vectors
attachVehicleOnToTrailer(vehicle, trailer, offset, coords, rotation, disableCollisions)

Parameters

ParameterTypeJavaScriptLua
vehicleVehiclenumberinteger
trailerVehiclenumberinteger
offsetXfloatnumbernumber
offsetYfloatnumbernumber
offsetZfloatnumbernumber
coordsXfloatnumbernumber
coordsYfloatnumbernumber
coordsZfloatnumbernumber
rotationXfloatnumbernumber
rotationYfloatnumbernumber
rotationZfloatnumbernumber
disableCollisionsfloatnumbernumber

Returns

Nothing. In JavaScript the call evaluates to undefined.

On LS:MP

⚠
Signature under review

LS:MP's table describes the parameters of this native differently from the current native database (void ATTACH_VEHICLE_ON_TO_TRAILER(Vehicle vehicle, Vehicle trailer, float offsetX, float offsetY, float offsetZ, float coordsX, float coordsY, float coordsZ, float rotationX, float rotationY, float rotationZ, BOOL disableCollisions)). Until the table is refreshed, some values may be passed or returned under the wrong type.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

This is the proper way of attaching vehicles to the car carrier, it's what Rockstar uses. Video Demo: https://www.youtube.com/watch?v=2lVEIzf7bgo

Reference

Namespace
Vehicle VEHICLE
In the game
void ATTACH_VEHICLE_ON_TO_TRAILER(Vehicle vehicle, Vehicle trailer, float offsetX, float offsetY, float offsetZ, float coordsX, float coordsY, float coordsZ, float rotationX, float rotationY, float rotationZ, float disableCollisions)
Hash
0x16B5E274BDE402F8

Open in the interactive natives reference