OnMarkerHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Minor changes + example)
Line 5: Line 5:
==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
player hitPlayer, bool matchingDimension
player hitElement, bool matchingDimension
</syntaxhighlight>  
</syntaxhighlight>  


*'''hitPlayer''': The player that hit the marker
*'''hitElement''': The element that hit the marker
*'''matchingDimension''': True if the player is in the same dimension as the marker he hit
*'''matchingDimension''': True if the element is in the same dimension as the marker he hit


==Source==
==Source==
The [[event system#Event source|source]] of this event is the [[marker]] that got hit by the player.
The [[event system#Event source|source]] of this event is the [[marker]] that got hit by the element.


==Example==  
==Example==  
Line 19: Line 19:
<!-- 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">
function MarkerHit ( hitPlayer, matchingDimension )
 
outputChatBox ( "hi" )
local myMarker = createMarker( -2596.6259765625, 579.3583984375, 15.626741409302, 'cylinder', 2.0, 255, 0, 0, 150 )
 
function MarkerHit( hitElement, matchingDimension )
        if getElementType( hitElement ) == "player" then
          outputChatBox( "Player inside myMarker", getRootElement(), 255, 255, 0 )
        elseif getElementType( hitElement ) == "vehicle" then
  outputChatBox( "Vehicle inside  myMarker", getRootElement(), 255, 255, 0 )
        end
end
end
addEventHandler("onMarkerHit", getRootElement (), MarkerHit)</syntaxhighlight>
addEventHandler( "onMarkerHit", myMarker, MarkerHit )</syntaxhighlight>


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

Revision as of 20:31, 3 November 2009

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

Parameters

player 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 will output 'hi' in the chatbox when the marker is hit.


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

function MarkerHit( hitElement, matchingDimension )
        if getElementType( hitElement ) == "player" then
          outputChatBox( "Player inside myMarker", getRootElement(), 255, 255, 0 )
        elseif getElementType( hitElement ) == "vehicle" then
	  outputChatBox( "Vehicle inside  myMarker", getRootElement(), 255, 255, 0 )
        end
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )

See Also

Marker events


Event functions