ItsMods

Full Version: About Health Bar...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Anyone tested these code? It is from MW2...
Code:
health_hud()
{

        self endon( "disconnect" );
        
        x = 80;
        y = 40;

        self.health_bar = NewClientHudElem( self );
        self.health_bar.x = x + 80;
        self.health_bar.y = y + 2;
        self.health_bar.alignX = "left";
        self.health_bar.alignY = "top";
        self.health_bar.horzAlign = "fullscreen";
        self.health_bar.vertAlign = "fullscreen";
        self.health_bar.alpha = 1;
        self.health_bar.foreground = 1;
        self.health_bar setshader( "black", 1, 8 );

        self.health_text = NewClientHudElem( self );
        self.health_text.x = x + 80;
        self.health_text.y = y;
        self.health_text.alignX = "left";
        self.health_text.alignY = "top";
        self.health_text.horzAlign = "fullscreen";
        self.health_text.vertAlign = "fullscreen";
        self.health_text.alpha = 1;
        self.health_text.fontScale = 1;
        self.health_text.foreground = 1;
        
        for ( ;; )
        {
                wait ( 0.05 );

                width = self.health / self.maxhealth * 300;
                width = int( max( width, 1 ) );
                self.health_bar setShader( "black", width, 8 );

                self.health_text SetValue( self.health );
        }
}
Yes it works..
yhea but its ugly... an health bar has to be green
(11-30-2010, 15:27)TheSaboteur Wrote: [ -> ]yhea but its ugly... an health bar has to be green

I don't know how to change to color in here...I don't have the exact color no...But I hope this code may help: (I code it)
Code:
HealthBar()
{
        useBar = createPrimaryProgressBar( -250 );
    useBarText = createPrimaryProgressBarText( -250 );
        useBarText settext("Health");
        for(;;)
        {
                usebar updateBar( self.health/100, 100 );
                if(self.health < 50 && self.health < 30 != true)
                {
                        usebar.color = (0,0,0);
                        usebar.bar.color = (0.9,1,0);
                        useBarText settext("^3Injuried");
                        usebar.alpha = 0.5;
                }
                else if(self.health < 30)
                {
                        usebar.color = (0,0,0);
                        usebar.bar.color = (1,0,0);
                        useBarText settext("^1Critical");
                        usebar.alpha = 1;
                }
                else if(self.health > 50)
                {
                        usebar.color = (0,0,0);
                        usebar.bar.color = (0,1,0);
                        useBarText settext("^2Normal");
                        usebar.alpha = 0.5;
                }
                wait 0.05;
        }
}
lol gl with the coding

To change back-bar idk2tell it
something.color = (colorA,colorB,colorC);
to change the bar itself
something.bar.color (balbala)
u can only make black or i think also blue shaders to fill in the bar...
(12-01-2010, 21:24)TheSaboteur Wrote: [ -> ]u can only make black or i think also blue shaders to fill in the bar...
X is a number
X,X,X is RGB color
(12-02-2010, 10:25)alistair3149 Wrote: [ -> ]
(12-01-2010, 21:24)TheSaboteur Wrote: [ -> ]u can only make black or i think also blue shaders to fill in the bar...
X is a number
X,X,X is RGB color

yes i was talking about the normal one...