how to detect height from the ground?
# support-forum
c
how to detect height from the ground? just like this cleo from this video:

https://www.youtube.com/watch?v=Wp3n9JzheGc

but on server side?
c
colandreas
g
Use mapandreas sir Here is a code for you to base yourself on, just adapt it according to your preferences.
Copy code
cpp
#include <mapandreas>

stock IsPlayerNearFloor(playerid, Float:range) {
 static Float:px, Float:py, Float:pz;
 GetPlayerPos(playerid, px, py, pz);
 MapAndreas_FindZ_For2DCoord(px, py, pz);
 return IsPlayerInRangeOfPoint(playerid, range, px, py, pz);
}
Colandreas would not be to detect collisions?
c
colandreas has
CA_FindZ_For2DCoord
for this stuff
afaik it's more accurate than the mapandreas version
c
nice, this can be made to anticipate cheat fly
w
MapAndreas does not detect custom objects. ColAndreas does + CA has more functions. Use CA. Abandon MapAndreas.
MapAndreas should be depracated IMO, it's pointless when there's CA
g
The question was about height detection, not about collision detection ;-;
w
Height detection is detected with CA
You yourself used MapAndreas
g
Ik, but you said it like it's for detecting collisions
w
Yeah, your example will not work on custom created objects
Hence why
CA_FindZ_For2DCoord
is better than
MapAndreas_FindZ_For2DCoord
MapAndreas looks for static San Andreas map height. CA for everything. Custom & static original map
c
ty
never used any of those libs are they heavy? just to understand @wonderful-traffic-197 @clever-air-16091 they do the same stuff, but ColAndreas detects when player is on custom objects, right? and on col andreas its just change the function?
Copy code
c++
#include <colandreas>

stock IsPlayerNearFloor(playerid, Float:range) {
 static Float:px, Float:py, Float:pz;
 GetPlayerPos(playerid, px, py, pz);
 CA_FindZ_For2DCoord(px, py, pz);
 return IsPlayerInRangeOfPoint(playerid, range, px, py, pz);
}
is colandreas to collision? i saw a video... could i use it to detect if player shots a vehicle or a wall before shot a player? some players are using hacks to kill other players behind cars and walls
b
Use
CA_RayCastLine
instead
CA_FindZ_For2DCoord
. https://github.com/Pottus/ColAndreas/issues/27#issuecomment-284179132
CA_FindZ_For2DCoord
could return wrong results when you are inside an interior or flying high
c
is it right?
Copy code
c++
#include <colandreas>


stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2) {
    return VectorSize(x1-x2, y1-y2, z1-z2);
}

stock Float:HeightFromFloor(playerid, Float:range) {
 static Float:px, Float:py, Float:pz;
 GetPlayerPos(playerid, px, py, pz);
 static Float:fx, Float:fy, Float:fz;
 CA_FindZ_For2DCoord(fx, fy, fz);
 new Float:tempdist = GetDistanceBetweenPoints(px, py, pz, fx, fy, fz);
 return tempdist;
}