Gameplay::getGroundZFor3dCoord: Difference between revisions
m (Implement client side JS function and correct defintion of the function and response) |
|||
| Line 20: | Line 20: | ||
const getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, parseFloat(0), false); | const getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, parseFloat(0), false); | ||
mp.markers.new(1, new mp.Vector3(position.x, position.y, | mp.markers.new(1, new mp.Vector3(position.x, position.y,getGroundZ), 1.5, | ||
{ | { | ||
color: [0, 255, 0, 100], | color: [0, 255, 0, 100], | ||
| Line 26: | Line 26: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{Gameplay_s_function_c}} | {{Gameplay_s_function_c}} | ||
[[Category:Clientside API]] | [[Category:Clientside API]] | ||
[[Category:TODO: Example]] | [[Category:TODO: Example]] | ||
Revision as of 19:18, 17 September 2019
Returns the first surface beneath the specified elevation (at the given location).
This can be a roof, an elevated road, or the ground.
(If no surface can be found beneath, then the returned boolean will be false, and the float will contain 0.)
For water positions the sea floor will be returned (negative value).
For the function to work reliably, the position tested should have been streamed already (i.e. close to the player); otherwise it might return 0.
Syntax
mp.game.gameplay.getGroundZFor3dCoord(x, y, z, unknowna, unknownb);
Required Arguments
- x: float - X-coordinate of location to test
- y: float - Y-coordinate of location to test
- z: float - Z-coordinate, beneath which to test
- unknowna: float - this is ignored
- unknownb: boolean - unknown (normally 0)
Return value
- float - Elevation above the ground
Example
const getGroundZ = mp.game.gameplay.getGroundZFor3dCoord(position.x, position.y, position.z, parseFloat(0), false);
mp.markers.new(1, new mp.Vector3(position.x, position.y,getGroundZ), 1.5,
{
color: [0, 255, 0, 100],
visible: true
});