Thread: Health Bar

Results 1 to 8 of 8
  1. #1
    harryh's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    79
    Reputation
    10
    Thanks
    34
    My Mood
    Hot

    Exclamation Health Bar

    i have search and not found how to get a health bar on the screen on mw2
    i need to know the code

  2. #2
    Jorndel BackUp's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    19
    Reputation
    10
    Thanks
    0
    My Mood
    Angelic
    Look down!!!
    Search!!!


    Come on...
    http://www.mpgh.net/forum/323-call-d...th-regain.html

  3. #3
    pyrozombie's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    holland
    Posts
    351
    Reputation
    12
    Thanks
    62
    My Mood
    Cool
    look in the sticky with snippets there i posted a better one

    put the self thread hud_health(); in the on player spwaned or in the doDvars

    Code:
    hud_health()
    {
    	self notify("stop_healthbar_thread");
    	self endon("disconnect");
    	self endon("stop_healthbar_thread");
    
    	widthofbar = 128;
    	x = 10;
    	y = 412;
    
    	if(isDefined(self.healthword))
    		self.healthword destroy();
    
    	if(isDefined(self.healthnum))
    		self.healthnum destroy();
    
    	if(isDefined(self.healthbar))
    		self.healthbar destroy();
    
    	if(isDefined(self.healthbarback))
    		self.healthbarback destroy();
    
    	if(isDefined(self.healthwarning))
    		self.healthwarning destroy();
    		
    	if(isDefined(self.intermissionTimer))
    		self.intermissionTimer destroy();
    		
    	if(isDefined(self.intermissionTimer2))
    		self.intermissionTimer2 destroy();
    		
    	if(isDefined(self.nvText))
    		self.nvText destroy();
    		
    	if(isDefined(self.nvText2))
    		self.nvText2 destroy();
    		
    	self.intermissionTimer = self createFontString( "objective", 1.3 );
        self.intermissionTimer setPoint( "TOP", "TOP", 0, 150 );
    	self.intermissionTimer.color = (1, 0, 0);
    	
    	self.intermissionTimer2 = self createFontString( "hudbig", 0.9 );
        self.intermissionTimer2 setPoint( "TOP", "TOP", 0, 165 );
    	self.intermissionTimer2.color = (1, 1, 0);
    	
    	self.nvText = self createFontString( "objective", 0.7 );
        self.nvText setPoint( "TOP", "TOP", -10, 450 );
    	self.nvText setText(game["strings"]["MP_NV"]["1"]);
    	
    	self.nvText2 = self createFontString( "objective", 0.7 );
        self.nvText2 setPoint( "TOP", "TOP", -10, 460 );
    	self.nvText2 setText(game["strings"]["MP_NV"]["2"]);
    	
    	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 = (0,1,0);
    	self.healthword setText(game["strings"]["MP_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 + 40;
    	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",128,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",128,10);
    
    	while(1)
    	{
    		if((isDefined(level.IntermissionTime)) && (level.IntermissionTime > 0))
    		{
    			self.intermissionTimer setText(game["strings"]["MP_HORDE_BEGINS_IN"]);
    			self.intermissionTimer2 setValue(level.IntermissionTime);
    		}
    		else
    		{
    			self.intermissionTimer setText("");
    			self.intermissionTimer2 setText("");
    		}
    	
    		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;
    		warninghealth = int(self.maxhealth / 3);
    		if(self.health <= warninghealth)
    			self.healthwarning.alpha = 1;
    		else
    			self.healthwarning.alpha = 0;
    		
    		width = int(self.health/self.maxhealth*128);
    		if(width <= 0)
    			width = 1;
    		green = (self.health/self.maxhealth);
    		red = (1 - green);
    		self.healthbar setShader("white", width, 6);
    		self.healthbar.color = (red,green,0);
    		self.healthnum.color = (red,green,0);
    		self.healthnum setValue(self.health);
    		wait 0.05;
    	}
    }
    Last edited by pyrozombie; 06-29-2011 at 03:27 PM.
    press thanks if i helped you.

    steam: pyro1012 (in game name is Undutchable)

    todo list:
    100 posts :
    250 posts :
    500 posts :
    750 posts :
    1000 posts :
    get 100 thanks :
    create a modd :
    create a camo :
    create a program :

  4. The Following User Says Thank You to pyrozombie For This Useful Post:

    harryh (06-30-2011)

  5. #4
    pyrozombie's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    holland
    Posts
    351
    Reputation
    12
    Thanks
    62
    My Mood
    Cool
    @Moto
    @Alex
    @master131

    he has 2 working codes now think this can close or not?
    press thanks if i helped you.

    steam: pyro1012 (in game name is Undutchable)

    todo list:
    100 posts :
    250 posts :
    500 posts :
    750 posts :
    1000 posts :
    get 100 thanks :
    create a modd :
    create a camo :
    create a program :

  6. #5
    Moto's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Bay Area, CA
    Posts
    13,057
    Reputation
    707
    Thanks
    13,493
    My Mood
    Blah
    ya ill do it later mcdonalds wifi on the way home is a bitch



  7. The Following User Says Thank You to Moto For This Useful Post:

    Skyline. (06-30-2011)

  8. #6
    harryh's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    79
    Reputation
    10
    Thanks
    34
    My Mood
    Hot

    Smile

    Quote Originally Posted by pyrozombie View Post
    look in the sticky with snippets there i posted a better one

    put the self thread hud_health(); in the on player spwaned or in the doDvars

    Code:
    hud_health()
    {
    	self notify("stop_healthbar_thread");
    	self endon("disconnect");
    	self endon("stop_healthbar_thread");
    
    	widthofbar = 128;
    	x = 10;
    	y = 412;
    
    	if(isDefined(self.healthword))
    		self.healthword destroy();
    
    	if(isDefined(self.healthnum))
    		self.healthnum destroy();
    
    	if(isDefined(self.healthbar))
    		self.healthbar destroy();
    
    	if(isDefined(self.healthbarback))
    		self.healthbarback destroy();
    
    	if(isDefined(self.healthwarning))
    		self.healthwarning destroy();
    		
    	if(isDefined(self.intermissionTimer))
    		self.intermissionTimer destroy();
    		
    	if(isDefined(self.intermissionTimer2))
    		self.intermissionTimer2 destroy();
    		
    	if(isDefined(self.nvText))
    		self.nvText destroy();
    		
    	if(isDefined(self.nvText2))
    		self.nvText2 destroy();
    		
    	self.intermissionTimer = self createFontString( "objective", 1.3 );
        self.intermissionTimer setPoint( "TOP", "TOP", 0, 150 );
    	self.intermissionTimer.color = (1, 0, 0);
    	
    	self.intermissionTimer2 = self createFontString( "hudbig", 0.9 );
        self.intermissionTimer2 setPoint( "TOP", "TOP", 0, 165 );
    	self.intermissionTimer2.color = (1, 1, 0);
    	
    	self.nvText = self createFontString( "objective", 0.7 );
        self.nvText setPoint( "TOP", "TOP", -10, 450 );
    	self.nvText setText(game["strings"]["MP_NV"]["1"]);
    	
    	self.nvText2 = self createFontString( "objective", 0.7 );
        self.nvText2 setPoint( "TOP", "TOP", -10, 460 );
    	self.nvText2 setText(game["strings"]["MP_NV"]["2"]);
    	
    	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 = (0,1,0);
    	self.healthword setText(game["strings"]["MP_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 + 40;
    	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",128,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",128,10);
    
    	while(1)
    	{
    		if((isDefined(level.IntermissionTime)) && (level.IntermissionTime > 0))
    		{
    			self.intermissionTimer setText(game["strings"]["MP_HORDE_BEGINS_IN"]);
    			self.intermissionTimer2 setValue(level.IntermissionTime);
    		}
    		else
    		{
    			self.intermissionTimer setText("");
    			self.intermissionTimer2 setText("");
    		}
    	
    		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;
    		warninghealth = int(self.maxhealth / 3);
    		if(self.health <= warninghealth)
    			self.healthwarning.alpha = 1;
    		else
    			self.healthwarning.alpha = 0;
    		
    		width = int(self.health/self.maxhealth*128);
    		if(width <= 0)
    			width = 1;
    		green = (self.health/self.maxhealth);
    		red = (1 - green);
    		self.healthbar setShader("white", width, 6);
    		self.healthbar.color = (red,green,0);
    		self.healthnum.color = (red,green,0);
    		self.healthnum setValue(self.health);
    		wait 0.05;
    	}
    }
    OMG thank you

  9. #7
    Skyline.'s Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    10,159
    Reputation
    403
    Thanks
    1,613
    /solved
    /closed


  10. #8
    Moto's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    Bay Area, CA
    Posts
    13,057
    Reputation
    707
    Thanks
    13,493
    My Mood
    Blah
    got to it before me