GetMarkerTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
This function returns the x,y,z-position of the specified markers target, the position it points to.
{{Server client function}}
This function returns the position of the specified marker's target, the position it points to. This only works for checkpoint markers and ring markers. For checkpoints it returns the position the arrow is pointing to, for ring markers it returns the position the ring is facing. You can set this target with [[setMarkerTarget]].


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
float float float getMarkerTarget ( element marker )   
float float float getMarkerTarget ( marker theMarker )   
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[Marker]]:getTarget|target|setMarkerTarget}}
===Required Arguments===  
===Required Arguments===  
*'''marker:''' The marker you wish to retieve the target position of.
*'''theMarker:''' The marker you wish to retrieve the target position of.
 


===Returns===
===Returns===
Returns three ''float'' if a target is set, ''false'' in the first variable and ''nil'' in the two others if the marker is invalid or no target is set.
Returns three ''float''s if a target is set, or ''false'' in the first variable and ''nil'' in the two others if the marker is invalid or no target is set.


==Example==  
==Example==  
This example outputs the markers target (if available) when a player hits a marker.
This example outputs the markers target (if available) when a player hits a marker.
<section show="true" name="Server" class="server">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function nextCheck(player)
function nextCheck(thePlayer)
local x,y,z = getMarkerTarget(source) -- get the marker target
local x,y,z = getMarkerTarget(source)   -- get the marker target
if (x ~= false) then -- if a target is set for the marker, then..
if x ~= false then                       -- if a target is set for the marker, then...
outputChatBox("Next checkpoint at: "..x.." "..y.." "..z,player) -- output a message with the coordinates
outputChatBox("Next checkpoint at: " .. x .. " " .. y .. " " .. z, thePlayer) -- output a message with the coordinates
end
end
end
end
addEventHandler("onMarkerHit",getRootElement(),nextCheck) -- add an event handler for the 'onMarkerHit' event
addEventHandler("onMarkerHit", root, nextCheck) -- add an event handler for the 'onMarkerHit' event
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Marker functions}}
{{Marker functions}}

Latest revision as of 08:04, 4 November 2020

This function returns the position of the specified marker's target, the position it points to. This only works for checkpoint markers and ring markers. For checkpoints it returns the position the arrow is pointing to, for ring markers it returns the position the ring is facing. You can set this target with setMarkerTarget.

Syntax

float float float getMarkerTarget ( marker theMarker )   

OOP Syntax Help! I don't understand this!

Method: Marker:getTarget(...)
Variable: .target
Counterpart: setMarkerTarget


Required Arguments

  • theMarker: The marker you wish to retrieve the target position of.

Returns

Returns three floats if a target is set, or false in the first variable and nil in the two others if the marker is invalid or no target is set.

Example

This example outputs the markers target (if available) when a player hits a marker.

Click to collapse [-]
Server
function nextCheck(thePlayer)
	local x,y,z = getMarkerTarget(source)    -- get the marker target
	if x ~= false then                       -- if a target is set for the marker, then...
		outputChatBox("Next checkpoint at: " .. x .. " " .. y .. " " .. z, thePlayer) -- output a message with the coordinates
	end
end
addEventHandler("onMarkerHit", root, nextCheck) -- add an event handler for the 'onMarkerHit' event

See Also