Problem with Health bar.
#1

Hi.
I have created a Health Bar with some colors.
When you have between 100 and 60HP, the color is green, when you have from 60 to 30 HP it's yellow, and from 30 to 0 it's red...
But this does not work, it always show like a yellow bar with 0 HP...
Here's the include of the Bar, and the code.
https://sampforum.blast.hk/showthread.php?tid=113443
pawn Код:
//On OnPlayerConnect:
SetTimer("ProgressBar", 500, 1);
forward ProgressBar();
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
    for (new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
    {
    new Float:health;
        GetPlayerHealth(playerid, health);
        if(health == 100 || health >= 60)
        {
        ShowProgressBarForPlayer(phealthsano[playerid]);
        SetProgressBarValue(phealthsano[playerid], health);
        UpdateProgressBar(phealthsano[playerid], playerid);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 60 || health >= 30)
        {
        ShowProgressBarForPlayer(phealthmezzo[playerid]);
        SetProgressBarValue(phealthmezzo[playerid]);
        UpdateProgressBar(phealthmezzo[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 30)
        {
        ShowProgressBarForPlayer(phealthmalato[playerid]);
        SetProgressBarValue(phealthmalato[playerid]);
        UpdateProgressBar(phealthmalato[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        }
    }
}
Help me please!
Reply
#2

I don't see anything wrong, But try this
pawn Код:
//On OnPlayerConnect:
SetTimer("ProgressBar", 500, 1);
forward ProgressBar();
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
    for (new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
    {
    new Float:health;
        GetPlayerHealth(playerid, health);
        if(health == 100 || health >= 60)
        {
        ShowProgressBarForPlayer(phealthsano[playerid]);
        SetProgressBarValue(phealthsano[playerid], health);
        UpdateProgressBar(phealthsano[playerid], playerid);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 60 || health >= 30)
        {
        ShowProgressBarForPlayer(phealthmezzo[playerid]);
        SetProgressBarValue(phealthmezzo[playerid]);
        UpdateProgressBar(phealthmezzo[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 30) || health >= 0)
        {
        ShowProgressBarForPlayer(phealthmalato[playerid]);
        SetProgressBarValue(phealthmalato[playerid]);
        UpdateProgressBar(phealthmalato[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        }
    }
}
Reply
#3

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
I don't see anything wrong, But try this
pawn Код:
//On OnPlayerConnect:
SetTimer("ProgressBar", 500, 1);
forward ProgressBar();
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
    for (new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
    {
    new Float:health;
        GetPlayerHealth(playerid, health);
        if(health == 100 || health >= 60)
        {
        ShowProgressBarForPlayer(phealthsano[playerid]);
        SetProgressBarValue(phealthsano[playerid], health);
        UpdateProgressBar(phealthsano[playerid], playerid);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 60 || health >= 30)
        {
        ShowProgressBarForPlayer(phealthmezzo[playerid]);
        SetProgressBarValue(phealthmezzo[playerid]);
        UpdateProgressBar(phealthmezzo[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 30) || health >= 0)
        {
        ShowProgressBarForPlayer(phealthmalato[playerid]);
        SetProgressBarValue(phealthmalato[playerid]);
        UpdateProgressBar(phealthmalato[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        }
    }
}
Same thing...
Reply
#4

Does it show green? or only Yellow everytime
Reply
#5

Can you show the definition of how you used CreateProgressBar?
By the way, if you want to change color you need to use SetProgressBarColor and I don't see it anywhere in the code.
Reply
#6

ProgressBar stuff may be this:
https://sampforum.blast.hk/showthread.php?tid=537468
Reply
#7

pawn Код:
//On OnPlayerConnect:
SetTimer("ProgressBar", 500, 1);
forward ProgressBar();
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
    for (new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
    {
    new Float:health;
        GetPlayerHealth(playerid, health);
        if(health == 100 && health >= 60)
        {
        ShowProgressBarForPlayer(phealthsano[playerid]);
        SetProgressBarValue(phealthsano[playerid], health);
        UpdateProgressBar(phealthsano[playerid], playerid);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 60 && health >= 30)
        {
        ShowProgressBarForPlayer(phealthmezzo[playerid]);
        SetProgressBarValue(phealthmezzo[playerid]);
        UpdateProgressBar(phealthmezzo[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmalato[playerid]);
        }
        else if(health < 30) && health >= 0)
        {
        ShowProgressBarForPlayer(phealthmalato[playerid]);
        SetProgressBarValue(phealthmalato[playerid]);
        UpdateProgressBar(phealthmalato[playerid], playerid);
        HideProgressBarForPlayer(phealthsano[playerid]);
        HideProgressBarForPlayer(phealthmezzo[playerid]);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)