GetRoofPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0160|1.5.8|20675| This function gets the Z level of the lowest roof above a point. It is required that the point is near eno...")
 
(Remove obsolete Requirements section)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{New feature/item|3.0160|1.5.8|20675|
{{Added feature/item|1.5.9|1.5.8|20675|This function gets the Z level of the lowest roof above a point. It is required that the point is near enough to the local player so that it's within the area where collision data is loaded.}}
This function gets the Z level of the lowest roof above a point.
It is required that the point is near enough to the local player so that it's within the area where collision data is loaded.}}


==Syntax==
==Syntax==
Line 11: Line 9:


===Required Arguments===
===Required Arguments===
*'''x''': A [[float]]ing point number representing the X world coordinate of the point.
*'''x''': A [[float]] representing the X world coordinate of the point.
*'''y''': A [[float]]ing point number representing the Y world coordinate of the point.
*'''y''': A [[float]] representing the Y world coordinate of the point.
*'''z''': A [[float]]ing point number representing the Z world coordinate of the point.
*'''z''': A [[float]] representing the Z world coordinate of the point.


===Returns===
===Returns===
Line 19: Line 17:


==Example==
==Example==
This example starts to shake the player's camera if there is no roof over it.
This example starts to shake the player's camera if there is no roof over him:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
setTimer (
setTimer (
function ( )
    function ()
local playerX, playerY, playerZ = getElementPosition ( localPlayer )
        local playerX, playerY, playerZ = getElementPosition (localPlayer)
local roofZ = getRoofPosition ( playerX, playerY, playerZ )
        local roofZ = getRoofPosition (playerX, playerY, playerZ)
setCameraShakeLevel ( ( roofZ ) and 0 or 255 )
        setCameraShakeLevel ((roofZ) and 0 or 255 )
end, 100, 0
    end, 100, 0
)
)
</syntaxhighlight>
</syntaxhighlight>
==Requirements==
{{Requirements|n/a|1.5.8-9.20675|}}


==See Also==
==See Also==
{{Client_world_functions}}
{{Client_world_functions}}

Latest revision as of 17:24, 7 November 2024

This function gets the Z level of the lowest roof above a point. It is required that the point is near enough to the local player so that it's within the area where collision data is loaded.

Syntax

float getRoofPosition ( float x, float y, float z )

Required Arguments

  • x: A float representing the X world coordinate of the point.
  • y: A float representing the Y world coordinate of the point.
  • z: A float representing the Z world coordinate of the point.

Returns

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

Example

This example starts to shake the player's camera if there is no roof over him:

setTimer (
    function ()
        local playerX, playerY, playerZ = getElementPosition (localPlayer)
        local roofZ = getRoofPosition (playerX, playerY, playerZ)
        setCameraShakeLevel ((roofZ) and 0 or 255 )
    end, 100, 0
)

See Also