GetVehicleTowingVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
{{Server client function}}
__NOTOC__
__NOTOC__
This function is used to get the vehicle that is towing another.
This function is used to get the vehicle that is towing another.
Line 14: Line 15:
This example will create a trailer and a trailer-tower, attach them, then check if they attached.
This example will create a trailer and a trailer-tower, attach them, then check if they attached.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
vehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain)
towingVehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain)
trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer
trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer
attachTrailerToVehicle ( vehicle, trailer ) -- attach them
attachTrailerToVehicle ( towingVehicle, trailer ) -- attach them
if ( getVehicleTowingVehicle ( trailer ) == vehicle ) then -- if it attached
if ( getVehicleTowingVehicle ( trailer ) == vehicle ) then -- if it attached
   outputChatBox ( "the vehicles were attached!" )
   outputChatBox ( "The vehicles were attached!" )
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:03, 17 August 2007

This function is used to get the vehicle that is towing another.

Syntax

vehicle getVehicleTowingVehicle ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle being towed.

Returns

Returns the vehicle that 'theVehicle' is being towed by, 'nil' if it isn't being towed.

Example

This example will create a trailer and a trailer-tower, attach them, then check if they attached.

towingVehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain)
trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer
attachTrailerToVehicle ( towingVehicle, trailer ) -- attach them
if ( getVehicleTowingVehicle ( trailer ) == vehicle ) then -- if it attached
  outputChatBox ( "The vehicles were attached!" )
end

See Also