This was made by @Yamato , he just asked me to post it here since he couldn't access his account right now.
"A icon that appears in HUD to "count" your health, is different to a health bar"
Precache the shader in init first:
Yamato's :OMA: tastic screenshot:
"A icon that appears in HUD to "count" your health, is different to a health bar"
Precache the shader in init first:
Code:
precacheshader("hint_health");
Code:
HealthIcon()
{
self endon("death");
self endon("disconnect");
if(!isDefined(self.healthicon))
{
self.healthicon = createIcon("hint_health",50,50);
self.healthicon setPoint("","",280,-190);
}
self thread KillHudElem(self.healthicon);
self thread MakeBigger();
while(1)
{
if(self.health > self.maxhealth)
self.healthicon.color = (1,1,1);
if(self.health > 75)
self.healthicon.color = (0.635,0.929,0.604);
if(self.health <= 75)
self.healthicon.color = (1,1,0.202);
if(self.health < 45)
self.healthicon.color = (1,0.651,0.23);
if(self.health > 20)
{
if(self.healthicon.width != 50)
self.healthicon.width = 50;
if(self.healthicon.height != 50)
self.healthicon.height = 50;
}
if(self.health < 20)
self.healthicon.color = (1,0.2,0.2);
wait 0.1;
}
}
MakeBigger()
{
self endon("death");
self endon("disconnect");
while(self.health < 20)
{
self.healthicon scaleOverTime(0.7,60,60);
wait 0.7;
self.healthicon scaleOverTime(0.7,50,50);
wait 0.7;
}
}
KillHudElem(elem)
{
self waittill_any("disconnect","death","spawned_player");
if(isdefined(elem))
elem destroy();
}
Yamato's :OMA: tastic screenshot: