Quick issue
#1

I've been playing around with the code a bit and haven't been able to find a good way to remove the extra decimals. I was wondering if there was a way you could do it so it could only show two decimals. For example, "Health: 49.00" instead of "Health: 49.000000"



Код HTML:
  	format(string, sizeof(string), "Health: %f, Armour: %f", PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmour]);
	SendClientMessage(playerid, COLOR_WHITE, string);
Reply
#2

pawn Код:
format(string, sizeof(string), "Health: %.2f, Armour: %.2f", PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmour]);
SendClientMessage(playerid, COLOR_WHITE, string);
Reply
#3

As SickAttack said, I would like to add that if you change the "x" in "%0.xf" it declares the number of decimals the float has,

also, if you want to turn it into an integer (no decimals), use floatround
pawn Код:
floatround(health, floatround_round); //This returns an integer, so make sure your replacing "%f" with "%d" while formatting
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)