OnMarkerHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(→‎Example: editing)
Line 20: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">


local myMarker = createMarker( -2596.6259765625, 579.3583984375, 15.626741409302, 'cylinder', 2.0, 255, 0, 0, 150 )
local myMarker = createMarker(-2596.625, 579.358, 15.626, 'cylinder', 2.0, 255, 0, 0, 150) -- create myMarker


function MarkerHit( hitElement, matchingDimension )
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler
        if getElementType( hitElement ) == "player" then
    local elementType = getElementType( hitElement ) -- get the hit element's type
          outputChatBox( "Player inside myMarker", getRootElement(), 255, 255, 0 )
    outputChatBox( elementType.." inside myMarker", getRootElement(), 255, 255, 0 )
        elseif getElementType( hitElement ) == "vehicle" then
  outputChatBox( "Vehicle inside myMarker", getRootElement(), 255, 255, 0 )
        end
end
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )</syntaxhighlight>
addEventHandler( "onMarkerHit", myMarker, MarkerHit )</syntaxhighlight>


{{See also/Server event|Marker events}}
{{See also/Server event|Marker events}}

Revision as of 11:02, 11 August 2011

This event is triggered when an element enters a marker created using createMarker.

Parameters

element hitElement, bool matchingDimension
  • hitElement: The element that hit the marker
  • matchingDimension: True if the element is in the same dimension as the marker he hit

Source

The source of this event is the marker that got hit by the element.

Example

This example will output a message what type of element has entered a marker.


local myMarker = createMarker(-2596.625, 579.358, 15.626, 'cylinder', 2.0, 255, 0, 0, 150) -- create myMarker

function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler
    local elementType = getElementType( hitElement ) -- get the hit element's type
    outputChatBox( elementType.." inside myMarker", getRootElement(), 255, 255, 0 )
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )

See Also

Marker events


Event functions