[HELP] Health TextDraw?
#1

Why this dont work? it gives me random numbers on my TextDraw, like: 145614251456


pawn Code:
public OnPlayerUpdate(playerid)
{
    new string[128];
    new Float:health;
    GetPlayerHealth(playerid, health);

    format(string, sizeof(string), "%i", health);
    TextDrawSetString(HealthTD, string);
    return 1;
}
Reply
#2

try making in a stock or a public and a timer for idk 5 sec? i had this problem with checking player health i tryed that it worked.

EDIT: Oops.
Reply
#3

Health is a float, and youre formatting with an integer signature, use %f
Reply
#4

Quote:
Originally Posted by SilentHuntR
View Post
Health is a float, and youre formatting with an integer signature, use %f
Yesh, and then use TextDrawShowForPlayer.
Reply
#5

Quote:
Originally Posted by MrDeath
View Post
Yesh, and then use TextDrawShowForPlayer.
Not neccesaary, TextDrawSetString is the only textdraw function that updates itself, very annoying
Reply
#6

Well? Im empty xD Here is the code:

pawn Code:
#include <a_samp>

new Text:HealthTD;

public OnFilterScriptInit()
{
    HealthTD = TextDrawCreate(251.000000, 434.000000, "-");
    TextDrawBackgroundColor(HealthTD, 255);
    TextDrawFont(HealthTD, 1);
    TextDrawLetterSize(HealthTD, 0.500000, 1.000000);
    TextDrawColor(HealthTD, -1);
    TextDrawSetOutline(HealthTD, 0);
    TextDrawSetProportional(HealthTD, 1);
    TextDrawSetShadow(HealthTD, 1);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/show", cmdtext, true, 10) == 0)
    {
        TextDrawShowForPlayer(playerid,HealthTD);
        return 1;
    }

    if (strcmp("/hide", cmdtext, true, 10) == 0)
    {
        TextDrawHideForPlayer(playerid,HealthTD);
        return 1;
    }
    return 0;
}


public OnPlayerUpdate(playerid)
{
    new string[128];
    new Float:health;
    GetPlayerHealth(playerid, health);

    format(string, sizeof(string), "%f", health);
    TextDrawSetString(HealthTD, string);
    return 1;
}
Reply
#7

Index the variable.
Reply
#8

Quote:
Originally Posted by _rAped
View Post
Index the variable.
Example Please =/
Reply
#9

Quote:
Originally Posted by SilentHuntR
View Post
Health is a float, and youre formatting with an integer signature, use %f
Do as he said, use %f instead of %i.
Reply
#10

Quote:
Originally Posted by Zamaroht
View Post
Do as he said, use %f instead of %i.
I did like he said, i canged from %i to %f

But then i get on my TextDraw: 15.000000 = Full health

And i want it like

Full Health = 100
ect...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)