floatround()
#1

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

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

Strange..
Reply
#3

Are you sure that GetPlayerSpeed returns a float?
Reply
#4

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)