OnElementColShapeHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (See Also for server events)
 
(5 intermediate revisions by 3 users not shown)
Line 8: Line 8:
</syntaxhighlight>  
</syntaxhighlight>  


*'''theColShape''': The [[colshape]] that this element collided with
*'''theColShape''': the [[colshape]] that this [[element]] collided with.
*'''matchingDimension''': True if the element and the colshape are in the same dimension
*'''matchingDimension''': a [[boolean]] representing if the [[element]] and the [[colshape]] are in the same [[dimension]].


==Source==
==Source==
Line 15: Line 15:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example prints type of the element which entered the created colshape to chatbox.
This example does...
<!-- 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...
colArea = createColCircle( 1400.0, -700.0, 5.0 ) -- create the colshape
blah()
 
--This line does this...
function elementColShapeHit( colShapeHit )
mooo
    if colShapeHit == colArea then -- if element entered the created colshape
        outputChatBox( getElementType( source ) .. " entered the colCircle!" ) -- print the type of the element to chatbox
    end
end
addEventHandler( "onElementColShapeHit", root, elementColShapeHit ) -- add a handler function for the event
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Element events}}
{{See also/Server event|Element events}}
[[Category:Needs Example]]

Latest revision as of 14:08, 31 December 2022

This event is triggered when an player or vehicle element collides with a colshape.

Parameters

colshape theColShape, bool matchingDimension

Source

The source of this event is the player or vehicle that collided with the colshape.

Example

This example prints type of the element which entered the created colshape to chatbox.

colArea = createColCircle( 1400.0, -700.0, 5.0 ) -- create the colshape

function elementColShapeHit( colShapeHit )
    if colShapeHit == colArea then -- if element entered the created colshape
        outputChatBox( getElementType( source ) .. " entered the colCircle!" ) -- print the type of the element to chatbox
    end
end
addEventHandler( "onElementColShapeHit", root, elementColShapeHit ) -- add a handler function for the event

See Also

Element events


Event functions