SA-MP Forums Archive
Problems with floatround() - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problems with floatround() (/showthread.php?tid=256665)



Problems with floatround() - admantis - 21.05.2011

Well, hello. I use floatround to convert a float to an integer (55.00 > 55) but I have this function:
pawn Код:
new Float:ZAngle = GetVehicleZAngle(GetPlayerVehicleID(i), ZAngle);
format(szString, 40, "HDG:~w~ %d", floatround(ZAngle, floatround_round));
TextDrawSetString(TD_8, szString);
My problem is that the textdraw always says

HDG: 1

It's always 1.
Thanks for your help.


Re: Problems with floatround() - Mauzen - 21.05.2011

pawn Код:
new Float:ZAngle = GetVehicleZAngle(GetPlayerVehicleID(i), ZAngle);
This executes GetVehicleZAngle first and puts the angle in ZAngle. But the function itself returns nothing special, in this case it just returns 1, and this is stored in ZAngle, overwriting the previously stored angle. Just ignore its return-value, and it will work:

pawn Код:
new Float:ZAngle;
GetVehicleZAngle(GetPlayerVehicleID(i), ZAngle);



Respuesta: Re: Problems with floatround() - admantis - 21.05.2011

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
pawn Код:
new Float:ZAngle = GetVehicleZAngle(GetPlayerVehicleID(i), ZAngle);
This executes GetVehicleZAngle first and puts the angle in ZAngle. But the function itself returns nothing special, in this case it just returns 1, and this is stored in ZAngle, overwriting the previously stored angle. Just ignore its return-value, and it will work:

pawn Код:
new Float:ZAngle;
GetVehicleZAngle(GetPlayerVehicleID(i), ZAngle);
Thank you for your quick response, I never thought of that