Problems with floatround()
#1

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.
Reply
#2

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);
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)