AttachTrailerToVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(fixed example: added required delay and changed to better position)
m (example: fixed pos)
Line 19: Line 19:
setTimer(
setTimer(
function()
function()
trailer = createVehicle ( 435, 500, 505, 40 )    -- create a trailer
trailer = createVehicle ( 435, 0, 0, 4 )    -- create a trailer
attachTrailerToVehicle ( newvehicle, trailer )  -- attach them
attachTrailerToVehicle ( newvehicle, trailer )  -- attach them
end, 50, 1)
end, 50, 1)

Revision as of 04:40, 30 August 2014

This function attaches a trailer type vehicle to a trailer-towing-type vehicle.

Syntax

bool attachTrailerToVehicle ( vehicle theVehicle, vehicle theTrailer )

Required Arguments

  • theVehicle: The vehicle you wish to attach a trailer to.
  • theTrailer: The trailer you wish to be attached.

Returns

Returns true if the vehicle's were successfully attached, false otherwise.

Example

This example will create a trailer and a trailer tower, then attach them.

newvehicle = createVehicle ( 515, 0, 0, 4 ) -- create a trailer tower (roadtrain)
setTimer(
	function()
		trailer = createVehicle ( 435, 0, 0, 4 )    -- create a trailer
		attachTrailerToVehicle ( newvehicle, trailer )   -- attach them
	end, 50, 1)

See Also