SA-MP Forums Archive
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: floatround() (/showthread.php?tid=256094)



floatround() - admantis - 19.05.2011

Okay so, I have this float number which I want to convert to integer, I know with floatround you can do it the following way:
pawn Код:
printf("%d", floatround(100.00)); // prints 100
But if I try this:
pawn Код:
printf("%d", floatround(GetPlayerSpeed(playerid, true)));
I get:
Код:
error 001: expected token: ",", but found ";"
Any tips?


Re: floatround() - Seven_of_Nine - 19.05.2011

I would try to put that in a variable, then printf the variable.

Strange..


Re: floatround() - MadeMan - 19.05.2011

Are you sure that GetPlayerSpeed returns a float?


Re: floatround() - Simon - 19.05.2011

Your code appears to be fine from the outside. The problem lies deeper than that line.

Is GetPlayerSpeed a #define with a semi-colon in it? You can get some unexpected behaviour with #define so check any related ones.

If you have no #define's related to that then I must ask, have you made a mistake with the line that the error is on? I don't see how the error would be on that line as you've posted it.


Re: floatround() - Klutty - 19.05.2011

Check the line over this line, thats usually the problem that it doesnt have a semicolon and only a simple comma sign.


Respuesta: floatround() - admantis - 19.05.2011

GetPlayerSpeed returns a float and it's a stock function. Anyways, thanks to Seven_Of_Nine, his technique worked.

pawn Код:
new p_Sp = GetPlayerSpeed(playerid, true);
printf("%d", floatround(p_Sp, floatround_round));
Regards.


Re: floatround() - cessil - 19.05.2011

you just needed a floatrounding type like the one you posted or floatround_floor (rounds down) floatround_ceil (rounds up) and floatround_round will round to the closest decimal