Convert float to interger?
#1

I have this
pawn Код:
new Float:pMeters[MAX_PLAYERS];
but how can i do this?
pawn Код:
format(string, sizeof(string), "Your distance is %d meters.", pMeters[playerid]);
I dont want to see this
Your distance is 500.3058293 meters.
How can convert it to this?
Your distance is 500 meters.
Reply
#2

https://sampwiki.blast.hk/wiki/Floatround
Reply
#3

Try this:
pawn Код:
format(string, sizeof(string), "Your distance is %d meters.", floatround(pMeters[playerid]));
Reply
#4

Thanks its working xD
Reply
#5

Also another method to get rid of the decimals would be to do this...

Код:
format(string, sizeof(string), "Your distance is %.0f meters.", pMeters[playerid]);
That will make it so there are zero decimals. With this method, you can choose how many decimals you want.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)