Powerup Timer Countdown
-
script that displays power up timers
Lines 27-30 allow you to change where the timers are displayed on the screen

#include maps\mp_utility;
#include common_scripts\utility;
#include maps\mp\gametypes_zm_hud_util;
#include maps\mp\zombies_zm_powerups;init()
{
level thread onPlayerConnect();
}onPlayerConnect()
{
for(;;)
{
level waittill("connected", player);
player thread playerPowerupTimers();
}
}playerPowerupTimers()
{
self endon("disconnect");
level endon("end_game");flag_wait("initial_blackscreen_passed"); self.doublePointsTimer = self createPowerupTimerHud(-42, -36); self.instaKillTimer = self createPowerupTimerHud(-14, -36); self.fireSaleTimer = self createPowerupTimerHud(14, -36); self.zombieBloodTimer = self createPowerupTimerHud(42, -36); zombieBloodWasActive = false; zombieBloodSeconds = 0; zombieBloodTick = 0; for(;;) { self updatePowerupTimer(self.doublePointsTimer, getTeamPowerupTime("zombie_powerup_point_doubler_on", "zombie_powerup_point_doubler_time")); self updatePowerupTimer(self.instaKillTimer, getTeamPowerupTime("zombie_powerup_insta_kill_on", "zombie_powerup_insta_kill_time")); self updatePowerupTimer(self.fireSaleTimer, getGlobalPowerupTime("zombie_powerup_fire_sale_on", "zombie_powerup_fire_sale_time")); zombieBloodActive = self isZombieBloodActive(); if(zombieBloodActive && !zombieBloodWasActive) { zombieBloodSeconds = 30; zombieBloodTick = 0; } if(zombieBloodSeconds > 0) { self updatePowerupTimer(self.zombieBloodTimer, zombieBloodSeconds); zombieBloodTick++; if(zombieBloodTick >= 4) { zombieBloodSeconds--; zombieBloodTick = 0; } } else self updatePowerupTimer(self.zombieBloodTimer, 0); zombieBloodWasActive = zombieBloodActive; wait 0.25; }}
createPowerupTimerHud(x, y)
{
hud = createFontString("small", 1.25);
hud setpoint("CENTER", "BOTTOM", x, y);
hud.alpha = 0;
hud.sort = 30;
hud.color = (1, 1, 1);
return hud;
}updatePowerupTimer(hud, timeLeft)
{
if(!isDefined(hud))
return;if(timeLeft > 0) { hud.alpha = 1; hud setvalue(getWholeSeconds(timeLeft)); } else { hud setText(""); hud.alpha = 0; }}
getTeamPowerupTime(activeVar, timeVar)
{
if(!isDefined(level.zombie_vars))
return 0;team = "allies"; if(isDefined(self.team)) team = self.team; if(!isDefined(level.zombie_vars[team])) return 0; if(!isDefined(level.zombie_vars[team][activeVar])) return 0; if(!level.zombie_vars[team][activeVar]) return 0; if(!isDefined(level.zombie_vars[team][timeVar])) return 0; return level.zombie_vars[team][timeVar];}
getGlobalPowerupTime(activeVar, timeVar)
{
if(!isDefined(level.zombie_vars))
return 0;if(!isDefined(level.zombie_vars[activeVar])) return 0; if(!level.zombie_vars[activeVar]) return 0; if(!isDefined(level.zombie_vars[timeVar])) return 0; return level.zombie_vars[timeVar];}
getWholeSeconds(timeLeft)
{
seconds = 0;while(seconds < timeLeft) seconds++; return seconds;}
isZombieBloodActive()
{
if(isDefined(self.ignoreme) && self.ignoreme)
return true;if(isDefined(self.zombie_blood) && self.zombie_blood) return true; if(isDefined(self.zombie_blood_on) && self.zombie_blood_on) return true; if(isDefined(self.zombieblood) && self.zombieblood) return true; return false;}
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login