OnPlayerMarkerHit: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Many errors)
 
(4 intermediate revisions by 3 users not shown)
Line 2: Line 2:
{{Server event}}
{{Server event}}
This event is triggered when a [[player]] hits a [[marker]].
This event is triggered when a [[player]] hits a [[marker]].
{{Note|This event is triggered for <b>players</b> only. Attaching this event to a marker does nothing.}}


==Parameters==
==Parameters==
Line 17: Line 18:
This example outputs when a player hits a marker.
This example outputs when a player hits a marker.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function markerAlert(markerHit,matchingDimension)
addEventHandler('onPlayerMarkerHit', root, function(marker, matchingDimension)
if (matchingDimension) then -- Make sure the player is in the same dimension as the marker (so they're actually going into it).
    if not matchingDimension then return end -- checks if the dimension of the player who activated the marker is the same as the one the marker is in (in this case, if not, it will stop here)
outputChatBox("You have just entered a marker.",source,255,255,0) -- Output that they are.
    outputChatBox('You have just entered a marker!', source, 255, 255, 0) -- output something
end
end)
end
addEventHandler("onPlayerMarkerHit",getRootElement(),markerAlert)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
{{See also/Server event|Player events}}
===Player events===
{{Player_events}}
===Event functions===
{{Event functions}}

Latest revision as of 14:54, 6 July 2024

This event is triggered when a player hits a marker.

[[{{{image}}}|link=|]] Note: This event is triggered for players only. Attaching this event to a marker does nothing.

Parameters

marker markerHit, bool matchingDimension

Source

The source of this event is the player that hit the marker.

Example

This example outputs when a player hits a marker.

addEventHandler('onPlayerMarkerHit', root, function(marker, matchingDimension)
    if not matchingDimension then return end -- checks if the dimension of the player who activated the marker is the same as the one the marker is in (in this case, if not, it will stop here)
    outputChatBox('You have just entered a marker!', source, 255, 255, 0) -- output something
end)

See Also

Player events


Event functions