ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. attachTrailerToVehicle

Function

attachTrailerToVehicle

ServerVehiclesIdentical to MTA:SA

Attaches a trailer or semi-trailer to a towing vehicle (truck, tractor, tow truck) for every player. Fires the onTrailerAttach event on the trailer; if a script cancels it (cancelEvent), the trailer is not attached. Players can also attach trailers normally in the game by reversing a truck onto them.

Syntax

bool attachTrailerToVehicle(vehicle truck, vehicle trailer)

Arguments

truckvehicle
The towing vehicle.
trailervehicle
The trailer (a different vehicle from the towing one).

Returns

true when the trailer was attached.

Example

local truck = createVehicle(403, 2200, -2250, 14)
local trailer = createVehicle(435, 2200, -2260, 14)
attachTrailerToVehicle(truck, trailer)

See also