GetMarkerTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:


===Returns===
===Returns===
Returns three ''float'' if a target is set, ''false'' otherwise.?
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.


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


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

Revision as of 23:18, 28 July 2007


This function returns the x,y,z-position of the specified markers target, the position it points to.

Syntax

float float float getMarkerTarget ( element marker )   

Required Arguments

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


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.

Example

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

function nextCheck(player)
	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,player) -- output a message with the coordinates
	end
end
addEventHandler("onMarkerHit",getRootElement(),nextCheck) -- add an event handler for the 'onMarkerHit' event

See Also