OnMarkerHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 20: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">


local myMarker = createMarker(-2596.625, 579.358, 15.626, 'cylinder', 2.0, 255, 0, 0, 150) -- create myMarker
playerMarker = createMarker(1601, 1212, 12.434, "cylinder", 15, 10, 244, 23, 2)


function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler
addEventHandler("onMarkerHit", playerMarker, function(hitElement)
    local elementType = getElementType( hitElement ) -- get the hit element's type
local tps = getPlayerFromName("MR Mariusz")
    outputChatBox( elementType.." inside myMarker", getRootElement(), 255, 255, 0 ) -- attach the element's type with the text, and output it
if tps then
end
local x, y, z, = getElementPosition(hitElement)
addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function</syntaxhighlight>
veh = createVehicle(416, x, y-2, z)
outputChatBox("You create vehicle!", hitElement)
else
outputChatBox("No, no!", player)
end  
end)
</syntaxhighlight>


==Issues==
==Issues==

Revision as of 21:38, 9 June 2020

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

Parameters

element hitElement, bool matchingDimension

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.


playerMarker = createMarker(1601, 1212, 12.434, "cylinder", 15, 10, 244, 23, 2)

addEventHandler("onMarkerHit", playerMarker, function(hitElement)
	local tps = getPlayerFromName("MR Mariusz")
	if tps then
		local x, y, z, = getElementPosition(hitElement)
		veh = createVehicle(416, x, y-2, z)
		outputChatBox("You create vehicle!", hitElement)
	else 
		outputChatBox("No, no!", player)
	end 
end)

Issues

Issue ID Description
#6098 If a marker was attached to another element, onMarkerHit won't be triggered

See Also

Marker events


Event functions