- Messages
- 1,322
- Reaction score
- 752
- Points
- 973
thats looks good. Nice work"Seals Alive: " + GetTeamPlayersAlive("allies") + "\nMercs Alive: " + GetTeamPlayersAlive("axis")); - Already done in my menu though
thats looks good. Nice work"Seals Alive: " + GetTeamPlayersAlive("allies") + "\nMercs Alive: " + GetTeamPlayersAlive("axis")); - Already done in my menu though
If you wanted the code more simple dothats looks good. Nice work
you could do this in literally 2 lines...
ZombieCount()
{
Zombies=getAIArray("axis");
return Zombies.size;
}
I think you can only use that in a gsc file.How do I add this to my cnfg file in notepad c++?? I copy and pasted it. I have my own server running anngd then dropped this in under the general settings but no go
Hi, how you set the health bar?I thought it would be useful to have a counter on-screen for showing the amount of currently existing Zombies on the map so I made the script:
Just callCode:drawZombiesCounter() { level.zombiesCountDisplay = createServerFontString("Objective" , 1.7); level.zombiesCountDisplay setPoint("RIGHT", "CENTER", 315, "CENTER"); thread updateZombiesCounter(); } updateZombiesCounter() { level endon("stopUpdatingZombiesCounter"); while(true) { zombiesCount = get_current_zombie_count(); level.zombiesCountDisplay setSafeText("Zombies: " + zombiesCount); waitForZombieCountChanged("stopUpdatingZombiesCounter"); } } recreateZombiesCounter() { level notify("stopUpdatingZombiesCounter"); thread updateZombiesCounter(); } waitForZombieCountChanged(endonNotification) { level endon(endonNotification); oldZombiesCount = get_current_zombie_count(); while(true) { newZombiesCount = get_current_zombie_count(); if(oldZombiesCount != newZombiesCount) { return; } wait 0.05; } }
in your init() function.Code:drawZombiesCounter()
Very important:
You have to use a String overflow fix with this, otherwise you will overflow. The function you're supposed to execute when the overflow fix occurs isI'm also usingCode:recreateZombiesCounter()
for setting the text which is an utility function of the overflow fix so make sure it exists for you as well.Code:setSafeText()
Also make sure that you have the following import statement:
It's needed for the get_current_zombie_count() function.Code:#include maps/mp/zombies/_zm_utility;
It will look like the following:
Enjoy
#include maps/mp/_utility;
#include common_scripts/utility;
#include maps/mp/zombies/_zm;
#include maps/mp/zombies/_zm_perks;
#include maps/mp/zombies/_zm_utility;
#include maps/mp/gametypes_zm/_hud_util;
#include maps/mp/gametypes_zm/_hud_message;
init()
{
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}
onPlayerSpawned()
{
level endon("end_game");
self endon("disconnect");
self waittill("spawned_player");
self thread health_bar_hud();
}
health_bar_hud()
{
level endon("end_game");
self endon("disconnect");
flag_wait("initial_blackscreen_passed");
health_bar = self createprimaryprogressbar();
if (level.script == "zm_buried")
{
health_bar setpoint(undefined, "BOTTOM", 0, -5);
}
else if (level.script == "zm_tomb")
{
health_bar setpoint(undefined, "BOTTOM", 0, -5);
}
else
{
health_bar setpoint(undefined, "BOTTOM", 0, -5);
}
health_bar.hidewheninmenu = 1;
health_bar.bar.hidewheninmenu = 1;
health_bar.barframe.hidewheninmenu = 1;
health_bar_text = self createprimaryprogressbartext();
if (level.script == "zm_buried")
{
health_bar_text setpoint(undefined, "BOTTOM", -75, -5);
}
else if (level.script == "zm_tomb")
{
health_bar_text setpoint(undefined, "BOTTOM", -75, -5);
}
else
{
health_bar_text setpoint(undefined, "BOTTOM", -75, -5);
}
health_bar_text.hidewheninmenu = 1;
while (1)
{
if (isDefined(self.e_afterlife_corpse))
{
if (health_bar.alpha != 0)
{
health_bar.alpha = 0;
health_bar.bar.alpha = 0;
health_bar.barframe.alpha = 0;
health_bar_text.alpha = 0;
}
wait 0.05;
continue;
}
if (health_bar.alpha != 1)
{
health_bar.alpha = 1;
health_bar.bar.alpha = 1;
health_bar.barframe.alpha = 1;
health_bar_text.alpha = 1;
}
health_bar updatebar(self.health / self.maxhealth);
health_bar_text setvalue(self.health);
wait 0.05;
}
}
Maybe try to replace setSafeText with setText?Hey, I know this is pretty old but is there any chance someone could help me out with this? I receive the following error in my dedicated server when trying to run this script:
******* script link error *******
**** 1 script error(s):
**** Unresolved external : "setsafetext" with 1 parameters in "maps/mp/_imcsx_gsc_studio.gsc" at line 1 ****
*********************************