BullyWiiPlaza
Modder
- Messages
- 214
- Reaction score
- 174
- Points
- 818
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 call
in your init() function.
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 is
I'm also using
for setting the text which is an utility function of the overflow fix so make sure it exists for you as well.
Also make sure that you have the following import statement:
It's needed for the get_current_zombie_count() function.
It will look like the following:
Enjoy
Code:
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;
}
}
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 is
Code:
recreateZombiesCounter()
Code:
setSafeText()
Also make sure that you have the following import statement:
Code:
#include maps/mp/zombies/_zm_utility;
It will look like the following:
Enjoy
Last edited: