PDA

View Full Version : Progressbar on rank.



Moczulak
6th November 2012, 19:37
Welcome.

I would like to make progress bar for rank.
Someone know how this could be done?

kung foo man
6th November 2012, 19:51
You can use some healthbar-script as rank-bar:



precache()
{
precacheShader("gfx/hud/hud@health_cross.tga");
precacheShader("gfx/hud/hud@health_back.tga");
precacheShader("gfx/hud/hud@health_bar.tga");
}

run()
{
deltaX = 7;
deltaY = 16;

self.healthcross = newClientHudElem(self);
self.healthcross.archived = true;
self.healthcross.horzAlign = "fullscreen";
self.healthcross.vertAlign = "fullscreen";
self.healthcross.alignX = "right";
self.healthcross.alignY = "top";
self.healthcross.x = 535 + deltaX; //543;
self.healthcross.y = 455 + deltaY;
self.healthcross setShader("gfx/hud/hud@health_cross.tga", 10-2, 10-2);

self.healthback = newClientHudElem(self);
self.healthback.archived = true;
self.healthback.horzAlign = "fullscreen";
self.healthback.vertAlign = "fullscreen";
self.healthback.alignX = "left";
self.healthback.alignY = "top";
self.healthback.x = 539 + deltaX; //547;
self.healthback.y = 455 + deltaY;
self.healthback setShader("gfx/hud/hud@health_back.tga", 90, 10-2);

self.healthbar = newClientHudElem(self);
self.healthbar.archived = true;
self.healthbar.horzAlign = "fullscreen";
self.healthbar.vertAlign = "fullscreen";
self.healthbar.alignX = "left";
self.healthbar.alignY = "top";
self.healthbar.x = 540 + deltaX; //548;
self.healthbar.y = 456 + deltaY;
self.healthbar.color = ( 0, 1, 0);
self.healthbar setShader("gfx/hud/hud@health_bar.tga", 88, 8-1);

self thread healthBarUpdate();
}

healthBarUpdate()
{
player = self;

oldhealth = self.health;
width = undefined;

while (isDefined(player))
{
if (isDefined(self.health) && self.health != oldhealth)
{
health = self.health / self.maxhealth;

width = int(health * 88);

if (width < 1)
width = 1;

player.healthbar setShader("gfx/hud/hud@health_bar.tga", width, 8-1);
player.healthbar.color = ( 1.0 - health, health, 0);

oldhealth = player.health;
}
wait 0.10;
}
}

Moczulak
6th November 2012, 19:55
Thanks man ! :)