I got a problem with the Health bar,
after you died the Health bar will show a bug what said you have 1 HP left under your current HP.
SO anyone can help me with them?
after you died the Health bar will show a bug what said you have 1 HP left under your current HP.
Quote:hud_health()
{
self endon("disconnect");
self endon("death");
level endon("game_ended");
x = 10;
y = 412;
self.maxwidthsize = 80;
basehealth = self.health;
self.healthperwidth = basehealth/self.maxwidthsize;
self.healthword = newclienthudelem(self);
self.healthword.alignX = "left";
self.healthword.alignY = "middle";
self.healthword.horzAlign = "fullscreen";
self.healthword.vertAlign = "fullscreen";
self.healthword.x = x;
self.healthword.y = y - 12;
self.healthword.alpha = 1;
self.healthword.sort = 2;
self.healthword.fontscale = 1.4;
self.healthword.color = (1,1,1);
self.healthword setText("Health:");
self.healthnum = newclienthudelem(self);
self.healthnum.alignX = "left";
self.healthnum.alignY = "middle";
self.healthnum.horzAlign = "fullscreen";
self.healthnum.vertAlign = "fullscreen";
self.healthnum.x = x + 35;
self.healthnum.y = y - 12;
self.healthnum.alpha = 1;
self.healthnum.sort = 2;
self.healthnum.fontscale = 1.4;
self.healthnum.color = (0,1,0);
self.healthbar = newclienthudelem(self);
self.healthbar.alignX = "left";
self.healthbar.alignY = "middle";
self.healthbar.horzAlign = "fullscreen";
self.healthbar.vertAlign = "fullscreen";
self.healthbar.x = x;
self.healthbar.y = y;
self.healthbar.alpha = 1;
self.healthbar.sort = 2;
self.healthbar.color = (0,1,0);
self.healthbar setShader("white",self.maxwidthsize,6);
self.healthbarback = newclienthudelem(self);
self.healthbarback.alignX = "left";
self.healthbarback.alignY = "middle";
self.healthbarback.horzAlign = "fullscreen";
self.healthbarback.vertAlign = "fullscreen";
self.healthbarback.x = x;
self.healthbarback.y = y;
self.healthbarback.alpha = 0.5;
self.healthbarback.sort = 1;
self.healthbarback.color = (0,0,0);
self.healthbarback setShader("white",self.maxwidthsize,10);
while(1)
{
if(self.sessionstate != "playing" || !isDefined(self.health) || !isDefined(self.maxhealth))
{
self.healthword.alpha = 0;
self.healthnum.alpha = 0;
self.healthbar.alpha = 0;
self.healthbarback.alpha = 0;
self.healthwarning.alpha = 0;
wait 0.05;
continue;
}
self.healthword.alpha = 1;
self.healthnum.alpha = 1;
self.healthbar.alpha = 1;
self.healthbarback.alpha = 0.5;
width = self.health / self.maxhealth * 100;
if(width <= 0)
width = 1;
if (self.health <= basehealth)
{
green = (self.health/basehealth);
red = (1 - green);
self.healthbar.color = (red,green,0);
self.healthnum.color = (red,green,0);
}
else
{
self.healthbar.color = (0,1,0);
self.healthnum.color = (0,1,0);
}
self.healthbar setShader("white", width, 6);
self.healthnum setValue(self.health);
wait 0.05;
}
}
SO anyone can help me with them?
Quote:Steam-> "p2tK"