Armour and Health
#1

Quick Question how do I only show health and armour as 64 or 100 and not 64.00000

pawn Code:
new Float: SH, Float: SA;
                GetPlayerHealth(id, SH);
                GetPlayerArmour(id, SA);
                format(string, sizeof(string), "Name: %s, ID: %d, Health: %f, Armour: %f, Money: %d", RPName(id), id, SH, SA, GetPlayerMoney(id));
Do I need to change the %f to %d or will it bug since health is a float?
Reply
#2

Yes,Just switch from float to an integer switch the %f to %d
Reply
#3

%f would be correct for it, no need to change it to %d
Reply
#4

pawn Code:
new Float:fMyFloat = 1.3;
new nSomeInt = _:fMyFloat;
 
//nSomeInt is now 1.
This should help, it converts floats into integers.
Reply
#5

Quote:
Originally Posted by nmader
View Post
pawn Code:
new Float:fMyFloat = 1.3;
new nSomeInt = _:fMyFloat;
 
//nSomeInt is now 1.
This should help, it converts floats into integers.
Not working..

pawn Code:
new Float: SH, Float: SA;
                GetPlayerHealth(id, SH);
                GetPlayerArmour(id, SA);
                new SpecHealth = _:SH;
                new SpecArmour = _:SA;
                format(string, sizeof(string), "Name: %s, ID: %d, Health: %d, Armour: %d, Money: %d", RPName(id), id, SpecHealth, SpecArmour, GetPlayerMoney(id));
returns health in 1120403456
Reply
#6

Leave it as it is (float) and format it with the below placeholder.
pawn Code:
%.0f
Reply
#7

Quote:
Originally Posted by _Zeus
View Post
Leave it as it is (float) and format it with the below placeholder.
pawn Code:
%.0f
Or you could just use floatround
pawn Code:
new Float: SH, Float: SA;
                GetPlayerHealth(id, SH);
                GetPlayerArmour(id, SA);
                //new SpecHealth = _:SH;
                //new SpecArmour = _:SA;
                format(string, sizeof(string), "Name: %s, ID: %d, Health: %d, Armour: %d, Money: %d", RPName(id), id, floatround(SpecHealth), floatround(SpecArmour), GetPlayerMoney(id));
Reply
#8

Why go through that extra hassle when the placeholder works just as good (and faster)? That makes no sense at all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)