OnTrailerAttach: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for server events)
m (added example)
Line 19: Line 19:
==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example does...
This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function detachTrailer(theTruck)
blah()
    detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer
--This line does this...
end
mooo
addEventHandler("onTrailerDetach", getRootElement(), detachTrailer)
</syntaxhighlight>
</syntaxhighlight>



Revision as of 02:54, 30 August 2009

This event is triggered when a trailer is attached to a truck.

Parameters

vehicle theTruck
  • theTruck: The truck vehicle that got attached to this trailer

Source

The source of this event is the trailer vehicle that the truck got attached to.

Cancel effect

If this event is canceled, the trailer will detach from the truck again.

Example

This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles

function detachTrailer(theTruck)
    detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer
 end
addEventHandler("onTrailerDetach", getRootElement(), detachTrailer)

See Also

Vehicle events


Event functions