- Documentation
- Server functions
- attachTrailerToVehicle
Function
attachTrailerToVehicle
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
detachTrailerFromVehicleDetaches a trailer from the towing vehicle for every player and firesonTrailerDetachon the trailer. A specific trailer can be given; then the function only works if that trailer is the one attached.getVehicleTowedByVehicleReturns the trailer the given vehicle is towing.getVehicleTowingVehicleReturns the vehicle that is towing the given trailer.