Return a float value
#1

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:
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;
}
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.
pawn Код:
new Float:test=GetDistance(playerid...coods...);// 1107778176.000000
If I put printf("%f",distanceb); before the return, I get 33.838558 printed.
pawn Код:
distanceb=floatsqroot((distz*distz)+(distancea*distancea));
    printf("%f",distanceb);//33.838558
    return distanceb;
}
What is wrong?
Reply


Messages In This Thread
Return a float value - by Badger(new) - 01.06.2010, 01:58
Re: Return a float value - by coole210 - 01.06.2010, 02:52
Re: Return a float value - by Simon - 01.06.2010, 02:55
Re: Return a float value - by coole210 - 01.06.2010, 02:58
Re: Return a float value - by Badger(new) - 01.06.2010, 03:03
Re: Return a float value - by smeti - 01.06.2010, 04:50
Re: Return a float value - by Stepashka - 01.06.2010, 04:56
Re: Return a float value - by Simon - 12.06.2010, 03:41

Forum Jump:


Users browsing this thread: 1 Guest(s)