Textdraws not updating
#1

Hey, any reason why this TD doesn't update?

pawn Код:
hp = TextDrawCreate(297.000000, 433.000000, "Health Level: Null");
    TextDrawBackgroundColor(hp, 255);
    TextDrawFont(hp, 1);
    TextDrawLetterSize(hp, 0.509999, 1.300000);
    TextDrawColor(hp, -1);
    TextDrawSetOutline(hp, 0);
    TextDrawSetProportional(hp, 1);
    TextDrawSetShadow(hp, 1);

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:health,hstring[30];
    GetPlayerHealth(playerid,health);
    format(hstring,sizeof(hstring),"Health Level: %s",health);
    TextDrawSetString(hp, hstring);
    TextDrawShowForPlayer(playerid, hp);
    return 1;
}
pawn Код:
new Text:hp;
And I got it showing at OnPlayerConnect. But it only shows as Null.
Reply
#2

Код:
format(hstring,sizeof(hstring),"Health Level: %s",floatround(health));
?
Reply
#3

Hide the textDraw then show it again. Also use %d in the format
Reply
#4

Quote:
Originally Posted by blackwave
Посмотреть сообщение
Код:
format(hstring,sizeof(hstring),"Health Level: %s",floatround(health));
?
No... That's the same as what I'm doing.

Quote:
Originally Posted by dice7
Посмотреть сообщение
Hide the textDraw then show it again. Also use %d in the format
I used %d, I had a typo :/ but no point in hiding it if I'm updating it. And when I get HP it goes: 110243101 for the players HP.
Reply
#5

Try to use %.2f

Because health is float.
Reply
#6

pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:health,hstring[30];
    GetPlayerHealth(playerid,health);
    format(hstring,sizeof(hstring),"Health Level: %.0f%%",health);
    TextDrawSetString(hp, hstring);
    TextDrawShowForPlayer(playerid, hp);
    return 1;
}
%% means one % sign.
Reply
#7

Quote:
Originally Posted by Axuj
Посмотреть сообщение
Try to use %.2f

Because health is float.
It just returns an extra .2f after the string of numbers.
Reply
#8

pawn Код:
new Text:hp [ MAX_PLAYERS ];
Reply
#9

Edit: NVM.

A small possibility, TextDrawSetString has now an automatic effect: If you use the function, the textdraw automatically updates. I'm wondering if it couldn't be possible if another user is interfering with the problem.
Reply
#10

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
but no point in hiding it if I'm updating it. And when I get HP it goes: 110243101 for the players HP.
Yes there is.
Try:
pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:health,hstring[30];
    GetPlayerHealth(playerid,health);
    format(hstring,sizeof(hstring),"Health Level: %d",health);
    TextDrawHideForPlayer(playerid, hp);
    hp = TextDrawCreate(297.000000, 433.000000, hstring);
    TextDrawShowForPlayer(playerid, hp);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)