SA-MP Forums Archive
Health shows 100.000000 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Health shows 100.000000 (/showthread.php?tid=414917)



Health shows 100.000000 - AphexCCFC - 10.02.2013

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)


Re: Health shows 100.000000 - zDevon - 10.02.2013

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));



Re: Health shows 100.000000 - Jefff - 10.02.2013

pawn Код:
%.0f



Re: Health shows 100.000000 - AphexCCFC - 10.02.2013

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;
}



Re: Health shows 100.000000 - MP2 - 10.02.2013

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


Re: Health shows 100.000000 - AphexCCFC - 10.02.2013

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


Re: Health shows 100.000000 - zDevon - 10.02.2013

OnPlayerTakeDamage?


Re: Health shows 100.000000 - AphexCCFC - 10.02.2013

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


Re: Health shows 100.000000 - AphexCCFC - 10.02.2013

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


Re: Health shows 100.000000 - zDevon - 10.02.2013

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.