Colored armour bar textdraw - won't work
#1

I'm trying to make armour bar looks like this health bar. The armour bar in colour but it won't work.

U made everything like health bar. And put OnPlayerUpdate

Код:
new Float:Armour;
    GetPlayerArmour(playerid,Armour);
    if(Armour >= 90)
    {
            TextDrawSetString(ArmourBar[playerid],"..........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 80)
    {
            TextDrawSetString(ArmourBar[playerid],".........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 70)
    {
            TextDrawSetString(ArmourBar[playerid],"........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 60)
    {
            TextDrawSetString(ArmourBar[playerid],".......");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 50)
    {
            TextDrawSetString(ArmourBar[playerid],"......");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 40)
    {
            TextDrawSetString(ArmourBar[playerid],".....");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
     }
    if(Armour >= 30)
    {
            TextDrawSetString(ArmourBar[playerid],"....");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
     }
    if(Armour >= 20)
    {
            TextDrawSetString(ArmourBar[playerid],"...");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 10)
    {
            TextDrawSetString(ArmourBar[playerid],"..");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour > 0)
    {
            TextDrawSetString(ArmourBar[playerid],".");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour = 0)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            return 1;
    }
But it won't work. Please help
Reply
#2

Won't work as in doesn't update when getting hurt, or is always empty/full? Changed code a little:

pawn Код:
new Float:Armour, arm;
GetPlayerArmour(playerid, Armour);
if(Armour = 0)
{
    TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
    return 1;
}
arm = floatround(Armour, floatround_round) / 10;
new dots[11];
memset(dots, '.', arm + 1);
TextDrawSetString(ArmourBar[playerid], dots);
TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
return 1;
@down:
I was asking how it is working now, not how is it supposed to work
Reply
#3

When he spawn he have 0 armour.
After when ge gets armour, it will show how much armour he have.

For example if I use my command "/setarm 100" so textdraw will show with full bar.

If I use command "/setarm 10" so textdraw will show a little. Just like Health bar works on this link I post.
Reply
#4

You have to use TextDrawHideForPlayer(playerid, ArmourBar[playerid]); before you make any changes on string, so the changes on textdraw string will be showed.

pawn Код:
new Float:Armour;
    GetPlayerArmour(playerid,Armour);
    if(Armour >= 90)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"..........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 80)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],".........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 70)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"........");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 60)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],".......");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 50)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"......");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 40)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],".....");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
     }
    if(Armour >= 30)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"....");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
     }
    if(Armour >= 20)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"...");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour >= 10)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],"..");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour > 0)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            TextDrawSetString(ArmourBar[playerid],".");
            TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
            return 1;
    }
    if(Armour = 0)
    {
            TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
            return 1;
    }
You can make the code more simple, I just wrote this to show you the mistake you've made.
Reply
#5

Don't work again :S
Reply
#6

In last if you use assignment operator = instead of comparison, and the expression returns true so you always hide the textdraw. Change it to ==.

Or use this code

[pawn]Try using exactly this code

pawn Код:
new Float:Armour, arm;
GetPlayerArmour(playerid, Armour);
TextDrawHideForPlayer(playerid, ArmourBar[playerid]);
if(Armour == 0.0) return 1;
arm = floatround(Armour, floatround_round) / 10;
new dots[11];
memset(dots, '.', arm + 1);
TextDrawSetString(ArmourBar[playerid], dots);
TextDrawShowForPlayer(playerid,ArmourBar[playerid]);
return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)