AttachTrailerToVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(OOP)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function attaches a trailer-type vehicle to a trailer-towing-type vehicle.
{{Server client function}}
This function attaches a trailer type vehicle to a trailer-towing-type vehicle.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool attachTrailerToVehicle ( vehicle theVehicle, vehicle theTrailer )</syntaxhighlight>
<syntaxhighlight lang="lua">bool attachTrailerToVehicle ( vehicle theVehicle, vehicle theTrailer )</syntaxhighlight>
 
{{OOP||[[vehicle]]:attachTrailer}}
===Required Arguments===
===Required Arguments===
*'''theVehicle''': The [[vehicle]] you wish to attach a trailer to.
*'''theVehicle''': the [[vehicle]] you wish to attach a trailer to.
*'''theTrailer''': The trailer you wish to be attached.
*'''theTrailer''': the trailer you wish to be attached.


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


==Example==
==Example==
This example will create a trailer and a trailer-tower, then attach them.
This example will create a trailer and a trailer tower, then attach them.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
vehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain)
newvehicle = createVehicle ( 515, 0, 0, 4 ) -- create a trailer tower (roadtrain)
trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer
setTimer(
attachTrailerToVehicle ( vehicle, trailer ) -- attach them
function()
trailer = createVehicle ( 435, 0, 0, 4 )   -- create a trailer
attachTrailerToVehicle ( newvehicle, trailer )   -- attach them
end, 50, 1)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Latest revision as of 15:46, 13 October 2014

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

Syntax

bool attachTrailerToVehicle ( vehicle theVehicle, vehicle theTrailer )

OOP Syntax Help! I don't understand this!

Method: vehicle:attachTrailer(...)


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