01.06.2010, 01:58
Hello I'm having some problem returning a float value. This function gets the distance from a player to a point using x,y and z:
The problem is using the distance float value.
If I set a float's value to the returned value, I get
1107778176.000000 instead of 33.838558.
If I put printf("%f",distanceb); before the return, I get 33.838558 printed.
What is wrong?
pawn Код:
stock GetDistance(playerid,Float:X,Float:Y,Float:Z){
new Float:distancea,Float:distanceb;
new Float:PX,Float:PY,Float:PZ;
GetPlayerPos(playerid,PX,PY,PZ);
new Float:distx=X-PX;
new Float:disty=Y-PY;
new Float:distz=Z-PZ;
distancea=floatsqroot((distx*distx)+(disty*disty));
distanceb=floatsqroot((distz*distz)+(distancea*distancea));
return distanceb;
}
If I set a float's value to the returned value, I get
1107778176.000000 instead of 33.838558.
pawn Код:
new Float:test=GetDistance(playerid...coods...);// 1107778176.000000
pawn Код:
distanceb=floatsqroot((distz*distz)+(distancea*distancea));
printf("%f",distanceb);//33.838558
return distanceb;
}