Health shows 100.000000
#1

How do I make my health show just 100 instead of 100.000000 when I type /stats? I'm using a float for the health (and %f for format string)
Reply
#2

Turn the float into an integer using floatround. So you might end up with something like this:
pawn Код:
new str1[24],Float:health;
GetPlayerHealth(playerid,health);
fomat(str1,sizeof(str1),"Health: %i",floatround(health,floatround_round));
Reply
#3

pawn Код:
%.0f
Reply
#4

Thanks, is it a bad idea to do this?:

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:health, query[500], pname[24];
    GetPlayerName(playerid, pname, 24);
    GetPlayerHealth(playerid, health);
    PlayerInfo[playerid][pHealth] = health;
    format(query, sizeof(query), "UPDATE playerdata SET Health=%f WHERE Username='%s'",
    PlayerInfo[playerid][pHealth],
    pname);
    mysql_query(query);
    return 1;
}
Reply
#5

That is an understatement and a half! Do you know how often that is called?!
Reply
#6

Quite often, but can't think of another way to check very often whether a players health has been reduced :P
Reply
#7

OnPlayerTakeDamage?
Reply
#8

Cheers, didn't know that existed, does it work for armour too?
Reply
#9

OnPlayerTakeDamage only works if other players give the damage?
What about if someone jumps off a rooftop :P
Reply
#10

According to the wiki it is called when a player takes any damage, from a player or not. As for armor I'm not so sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)