Colored armour bar textdraw - won't work -
Saddin - 09.07.2013
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
Re: Colored armour bar textdraw - won't work -
Misiur - 10.07.2013
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
Re: Colored armour bar textdraw - won't work -
Saddin - 10.07.2013
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.
Re: Colored armour bar textdraw - won't work -
Calabresi - 10.07.2013
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.
Re: Colored armour bar textdraw - won't work -
Saddin - 10.07.2013
Don't work again :S
Re: Colored armour bar textdraw - won't work -
Misiur - 10.07.2013
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;