Problem with float - 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: Problem with float (
/showthread.php?tid=593580)
Problem with float -
lucamsx - 07.11.2015
so, i wanted to get players health and show it in 3dtext above his head. everything is fine besides health is always "0.000".
Код:
new Float:pHealth;
GetPlayerHealth(playerid, pHealth);
code below is in OnPlayerSpawn
Код:
if(strcmp(name,"nickname",true) == 0)
{
format(stc,sizeof(stc),"\n\n\n{EDEDED}%s\n{B322BD}(Gang Member)\n{FFFFFF}HP: %.0f",name, pHealth);
Update3DTextLabelText(PlayerLabel[playerid], 0xFFFFFFFF, stc);
}
what's wrong with that?
Re: Problem with float -
ikey07 - 07.11.2015
Try to put that pHealth inside that strcmp aswell, or try to make blank "%s %.0f",name,pHealth);
just to see what it does.
Re: Problem with float -
lucamsx - 07.11.2015
okay, i fixed it already, but now i have another problem.
how do i round the amounts of health/armour? i wanted to show it like "100", not "100.00000".
Re: Problem with float -
thefirestate - 07.11.2015
Use this:
https://sampwiki.blast.hk/wiki/Floatround
It will convert the float value to an integer. (@ikey, Ooh, hey Ikey, didn't expected to see you.)