Originally Posted by
Earliboy
Hello,
i don't wanna waste hudelems so i want to use a shader + an value
PHP Code:
self.healthbar_cross = newClientHudElem(self);
self.healthbar_cross setShader("gfx/hud/hud@health_cross.tga", 10, 10);
self.healthbar_cross.alignX = "right";
self.healthbar_cross.alignY = "top";
self.healthbar_cross.sort = 9001;
self.healthbar_cross.x = x - 20;
self.healthbar_cross.y = y2 - 15;
I want to add self.healthbar_cross setValue(self.preHealth);
But if i do that, the shader doesnt shows anymore.
Any ideas? Or is it just not possible?
And no, i don't want to use another hudelem cause the elem limit for players (thats just useless :/ )
There is no point writing a health bar hud element as their is a stock one. It was never eneabled because Infinity Ward decided to abandon the old COD1 health system and go with the regeneration health system instead. The only thing you have to do with a health bar is:
1. Decide where it is going to go;
2. Set the client cvars so that it will show.
1. To determine where the health bar will go, look in ui_mp/hud.menu and search for "health bar". You will find this:
PHP Code:
// HEALTH BAR
menuDef
{
name "Health"
fullScreen MENU_FALSE
visible MENU_TRUE
rect -152 -20 0 0 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_BOTTOM
itemDef
{
name "healthbarback"
rect 13 0 130 12
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_back.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
}
itemDef
{
name "healthbar"
rect 14 1 128 10
forecolor 0.7 0.4 0.0 1.0
background "gfx/hud/hud@health_bar.tga"
ownerdraw CG_PLAYER_BAR_HEALTH
visible MENU_TRUE
decoration
}
itemDef
{
name "healthbarcross"
rect 0 0 12 12
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_cross.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
}
}
Those are the stock settings. I changed them in my Demon mod to these:
PHP Code:
// HEALTH BAR
menuDef
{
name "Health"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 45 448 640 40
itemDef
{
name "healthbarback"
rect 557.5 12 90 7
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_back.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
itemDef
{
name "healthbar"
rect 558.5 13 88 5
forecolor 0.7 0.4 0.0 1.0
background "gfx/hud/hud@health_bar.tga"
ownerdraw CG_PLAYER_BAR_HEALTH
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
itemDef
{
name "healthbarcross"
rect 545 11 10 10
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_cross.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
}
This places the health bar here:
(lower right-hand corner in green).
2. To enable the health bar, just set 2 cvars on the client:
PHP Code:
self setClientCvar( "cg_drawhealth", "1" );
self setClientCvar( "hud_fade_healthbar", "0" );
That's all you have to do. Believe me - the stock health bar is far superior to anything you can script because it glows and pluses when the player is damaged in a way that would be difficult to script.