getGroundPosition | Multi Theft Auto: Wiki Skip to content

getGroundPosition

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function gets the Z level of the highest ground below a point.

Syntax

float getGroundPosition ( float x, float y, float z )
Required Arguments
  • x: A floating point number representing the X world coordinate of the point.
  • y: A floating point number representing the Y world coordinate of the point.
  • z: A floating point number representing the Z world coordinate of the point.

Returns

  • float: value

Returns a float with the highest ground-level Z coord if parameters are valid, 0 if the point you tried to test is outside the loaded world map, false otherwise.

Code Examples

shared

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

function isPlayerUnderCover ( thePlayer )
--we get the player's position
local px, py, pz = getElementPosition ( thePlayer )
--we'll check for ground level at the player's position, and also 500 units over him.
--if these ground levels match, it must mean there were no obstacles (such as a ceiling) over the player,
return getGroundPosition ( px, py, pz ) ~= getGroundPosition ( px, py, pz + 530 )
end

See Also

World Functions