GetGroundPosition

From Multi Theft Auto: Wiki
Revision as of 23:31, 28 February 2007 by Jbeta (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Dialog-information.png This article needs checking.

Reason(s): what's the maximum distance from the player we can check?

This function gets the ground level of the nearest floor level below a point. It is required that the point is near enough to the player so that it's within the area where world map data is loaded.

Syntax

float getGroundPosition ( float x, float y, float z )

Required Arguments

  • x: A floating point number representing the X coordinate on the map.
  • y: A floating point number representing the Y coordinate on the map.
  • z: A floating point number representing the Z coordinate on the map.

Returns

Returns a float with the highest floor-level Z coord if parameters are valid, false otherwise.

Example

This clientside function determines if a player is under a ceiling.

function isPlayerUndercover ( player )
	--we get the player's position and store it in three variables
	local px, py, pz = getPlayerPosition ( player )
	--if the floor level for the player is the same when we measure it way up (let's say 200 units),
	--it must mean there are no obstacles (ceilings) over the player: the function returns false (not undercover)
	if getGroundPosition ( px, py, pz ) == getGroundPosition ( px, py, pz + 200 ) then return false
	--otherwise, there must be an object over him: the function returns true (undercover)
	else return true
	end
end

See Also