SA-MP Forums Archive
Textdraws - 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: Textdraws (/showthread.php?tid=456316)



Textdraws - BigGroter - 05.08.2013

pawn Код:
new Float:hp;
    GetPlayerHealth(playerid, hp);
   
    format(string, sizeof(string), "Health: %f", floatround(hp));
    PlayerTextDrawSetString(playerid, Textdraw1[playerid], string);
    PlayerTextDrawShow(playerid, Textdraw1[playerid]);
Why does it display as "Health: 0.00000000000000000000" in game?


Re: Textdraws - ScRipTeRi - 05.08.2013

pawn Код:
new Float:hp;
    GetPlayerHealth(playerid, hp);
   
    format(string, sizeof(string), "Health:%.1f", floatround(hp));
    PlayerTextDrawSetString(playerid, Textdraw1[playerid], string);
    PlayerTextDrawShow(playerid, Textdraw1[playerid]);



Re: Textdraws - BigGroter - 05.08.2013

Yeah, I already tried this. The problem is that it says that I have 0 health.


Re: Textdraws - ScRipTeRi - 05.08.2013

pawn Код:
new Float:hp;
    GetPlayerHealth(playerid, hp);
   
    format(string, sizeof(string), "Health:%.0f%", floatround(hp));
    PlayerTextDrawSetString(playerid, Textdraw1[playerid], string);
    PlayerTextDrawShow(playerid, Textdraw1[playerid]);



Re: Textdraws - morocco - 05.08.2013

pawn Код:
if(!strcmp(cmdtext, "/health"))
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                new Float:hp, string[256];
                GetPlayerHealth(playerid, hp);

                format(string, sizeof(string), "Health: %d", floatround(hp));
                SendClientMessage(i, -1,string);
              //  PlayerTextDrawSetString(playerid, Textdraw1[playerid], string);
              //  PlayerTextDrawShow(playerid, Textdraw1[playerid]);
            }
        }
        return 1;
    }



Re: Textdraws - BigGroter - 05.08.2013

Ah yes, floatround turns it into an integer, thanks both.