Call of Duty: Black Ops III

Call of Duty: Black Ops III

Not enough ratings
[Scripting] Adding A Health Bar
By Mysti and 1 collaborators
   
Award
Favorite
Favorited
Unfavorite
Introduction
Here goes another short and simple guide that could be added to any number of maps, or if you just want to turn it into a mod for the base maps to get a feel for scripting. It's pretty simple, only one function. So let's go!
Scripting Requirements
Yep! That's right there is nothing you need to in Radiant. So first things first, we're going to register a callback. If you're familar with C# a callback is basically an event. If you're not familar with any programming language, a callback is something that that "fires" when something happens. In this case we're going to register the on_spawned() callback. So add this line to the bottom of your MAPNAME.gsc file's main funcion
callback::on_spawned( &on_player_spawned );
below;
level.pathdist_type = PATHDIST_ORIGINAL;

Now we're going to create a function like so
function on_player_spawned() { self endon("disconnect"); self endon("death"); self.HealthBar = zm_utility::create_simple_hud(self); self.HealthBar.horzAlign = "center"; self.HealthBar.vertAlign = "middle"; self.HealthBar.alignX = "middle"; self.HealthBar.alignY = "middle"; self.HealthBar.y = 230; self.HealthBar.x = 5; self.HealthBar.foreground = 1; self.HealthBar.fontscale = 2.0; self.HealthBar.alpha = 1; self.HealthBar.color = ( 0.423, 0.004, 0 ); //Red Green Blue. 1 is 255 self.HealthText = zm_utility::create_simple_hud(self); self.HealthText.horzAlign = "center"; self.HealthText.vertAlign = "middle"; self.HealthText.alignX = "right"; self.HealthText.alignY = "middle"; self.HealthText.y = 230; self.HealthText.x = -1; self.HealthText.foreground = 1; self.HealthText.fontscale = 2.0; self.HealthText.alpha = 1; self.HealthText.color = ( 0.423, 0.004, 0 ); //Red Green Blue. 1 is 255 self.HealthText SetText("Health: "); while(1) { self.HealthBar SetValue(self.health); wait 0.1; } }
This creates 2 HUD Elemts for the player who spawned, so not everyone will get to see them. You could make it so it reflects everyones elses health and make it create hud elements for each, but that is out of scope for this guide.

Also, make sure that
#using scripts\zm\_zm_utility;
is somewhere up the top of your file with every other using statements.
Final Words
Well, that's that. You have now added a health bar for the player to the map. You could just turn this into a mod, and you could play it on any map you want so long as it doesn't have a mod bundled with it. See you guys all in the next one.

Thanks, Johnathon.
13 Comments
Majid80D 27 May, 2017 @ 5:10am 
thx
Mysti  [author] 26 May, 2017 @ 9:52pm 
Then you're a special snow flake. This isn't for you then.
stefvn 26 May, 2017 @ 12:17pm 
@^1Elzar N-G are you stupid ore trying to be ?>
variable 26 May, 2017 @ 8:29am 
i don even have mod tools even how do i even know how to make a single mod or a single mod tools
Mysti  [author] 25 May, 2017 @ 8:46pm 
You need to make a mod in the mod tools first.
variable 25 May, 2017 @ 8:37pm 
i cant even i just don know wheres the mapname.zone is at
Mysti  [author] 24 May, 2017 @ 1:22pm 
No, it uses the mod tools to create a healthbar HUD, but you will need to be playing on a server that has this mod enabled to use it.
stefvn 24 May, 2017 @ 12:42pm 
Can you get VAC Banned in mutly player for this
Mysti  [author] 24 May, 2017 @ 2:15am 
It's really not that hard. What are you getting stuck on?
variable 24 May, 2017 @ 1:27am 
just make a video about it
so i can do it