Little fail,help needed D:
#1

Hey,
So i made this thing that shows you how much health you have over the health bar.
Part of the code:
pawn Код:
forward Fuck123(playerid);
public Fuck123(playerid)
{
    new str[4],Float:h;
    GetPlayerHealth(playerid,h);
    format(str,sizeof(str),"%f",h);
  TextDrawSetString(PlayerInfo[playerid][pInfoTxt],str);
  TextDrawShowForPlayer(playerid,PlayerInfo[playerid][pInfoTxt]);
}
Well the problem is that for example if i have 100% left,it shows 100,but if i have 10,20,30,40-99
it shows: 10. or 20. etc.
Well It's ugly,anyway to fix it guys?
Thanks in advance.

EDIT:
Would this work? :
pawn Код:
forward Fuck123(playerid);
public Fuck123(playerid)
{
    new Float:h;
    if(GetPlayerHealth(playerid,h) >= 100)
    {
        new str[4];
        GetPlayerHealth(playerid,h);
        format(str,sizeof(str),"%f",h);
    TextDrawSetString(PlayerInfo[playerid][pInfoTxt],str);
    }
    else if(GetPlayerHealth(playerid,h) < 100 || h > 10)
    {
      new str2[3];
      GetPlayerHealth(playerid,h);
      format(str2,sizeof(str2),"%f",h);
      TextDrawSetString(PlayerInfo[playerid][pInfoTxt],str2);
    }
    else if(GetPlayerHealth(playerid,h) < 10)
    {
      new str3[2];
      GetPlayerHealth(playerid,h);
      format(str3,sizeof(str3),"%f",h);
        TextDrawSetString(PlayerInfo[playerid][pInfoTxt],str3);
    }
}
Reply
#2

maybe it'll work by modifying that one line to format an integer instead of a float?
Код:
	format(str,sizeof(str),"%3d",floatround(h,floatround_floor));
Reply
#3

new str[50],Float:h;
Reply
#4

Quote:
Originally Posted by Babul
maybe it'll work by modifying that one line to format an integer instead of a float?
Код:
	format(str,sizeof(str),"%3d",floatround(h,floatround_floor));
Thanks works perfectly
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)