Hp label problem
#1

So i've this code to show a textlabel with the hp/armour of the player, the problem is: it keeps saying: Hp 0 / Armour 0, why?

pawn Код:
new Float:hp, Float:am;
    GetPlayerHealth(playerid,hp);
    GetPlayerArmour(playerid,am);
    new stringk[128];
    format(stringk,sizeof(stringk),"{FFFFFF}Hp: {F70505}%0.2f {FFFFFF}- Armour: {F70505}%0.2f",hp,am);
    new Text3D:PlayerLabel = Create3DTextLabel(stringk, -1, 0.0, 0.0, 40.0, 20.0, 0, 1);
    Attach3DTextLabelToPlayer(PlayerLabel, i, 0.0, 0.0, 0.47);
I placed it on OnPlayerSpawn.
Reply
#2

Well did you print the playerid and hp variable out to see what it's giving you?
Reply
#3

pawn Код:
new Float:hp, Float:am;
    hp = GetPlayerHealth(playerid);
    am = GetPlayerArmour(playerid);
    new stringk[128];
    format(stringk,sizeof(stringk),"{FFFFFF}Hp: {F70505}%0.2f {FFFFFF}- Armour: {F70505}%0.2f",hp,am);
    new Text3D:PlayerLabel = Create3DTextLabel(stringk, -1, 0.0, 0.0, 40.0, 20.0, 0, 1);
    Attach3DTextLabelToPlayer(PlayerLabel, i, 0.0, 0.0, 0.47);
Reply
#4

3D Labels are unreliable and prone to bugging out when attaching, when you do get it to work expect it break when you get multiple players online (missing labels and overlapping labels) happens all the time and not recommended.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)