Problem with float
#1

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?
Reply
#2

Try to put that pHealth inside that strcmp aswell, or try to make blank "%s %.0f",name,pHealth);
just to see what it does.
Reply
#3

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".
Reply
#4

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.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)