Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. Game Timer

Game Timer

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
2 Posts 1 Posters 132 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • vnm_420undefined Offline
    vnm_420undefined Offline
    vnm_420
    wrote last edited by
    #1

    Timer that keeps track of total play time along with current round time and previous round time
    Screenshot 2026-04-30 224255.png

    Lines 26-28 allow you to change where its displayed

    #include maps\mp_utility;
    #include common_scripts\utility;
    #include maps\mp\gametypes_zm_hud_util;

    init()
    {
    level thread onPlayerConnect();
    }

    onPlayerConnect()
    {
    for(;;)
    {
    level waittill("connected", player);
    player thread playerGameTimers();
    }
    }

    playerGameTimers()
    {
    self endon("disconnect");
    level endon("end_game");

    flag_wait("initial_blackscreen_passed");
    
    self.gameTimerHud = self createTimerHud("Game:", 400, 120);
    self.roundTimerHud = self createTimerHud("Round:", 400, 145);
    self.lastRoundTimerHud = self createTimerHud("Last:", 395, 170);
    
    gameSeconds = 0;
    roundSeconds = 0;
    lastRoundSeconds = 0;
    currentRound = getCurrentRound();
    
    for(;;)
    {
    	newRound = getCurrentRound();
    
    	if(newRound != currentRound)
    	{
    		lastRoundSeconds = roundSeconds;
    		roundSeconds = 0;
    		currentRound = newRound;
    	}
    
    	self.gameTimerHud setText("Game: " + formatTimer(gameSeconds));
    	self.roundTimerHud setText("Round: " + formatTimer(roundSeconds));
    	self.lastRoundTimerHud setText("Last: " + formatTimer(lastRoundSeconds));
    
    	wait 1;
    
    	gameSeconds++;
    	roundSeconds++;
    }
    

    }

    createTimerHud(label, x, y)
    {
    hud = createFontString("small", 1.35);
    hud setpoint("RIGHT", "TOP", x, y);
    hud.alpha = 1;
    hud.sort = 20;
    hud.color = (1, 1, 1);
    hud setText(label + " 00:00");
    return hud;
    }

    getCurrentRound()
    {
    if(isDefined(level.round_number))
    return level.round_number;

    if(isDefined(level.round))
    	return level.round;
    
    if(isDefined(level.zombie_round))
    	return level.zombie_round;
    
    return 1;
    

    }

    formatTimer(totalSeconds)
    {
    hours = 0;
    minutes = 0;
    seconds = totalSeconds;

    while(seconds >= 3600)
    {
    	hours++;
    	seconds -= 3600;
    }
    
    while(seconds >= 60)
    {
    	minutes++;
    	seconds -= 60;
    }
    
    if(hours > 0)
    	return hours + ":" + twoDigits(minutes) + ":" + twoDigits(seconds);
    
    return minutes + ":" + twoDigits(seconds);
    

    }

    twoDigits(value)
    {
    if(value < 10)
    return "0" + value;

    return "" + value;
    

    }

    1 Reply Last reply
    1
    • vnm_420undefined Offline
      vnm_420undefined Offline
      vnm_420
      wrote last edited by
      #2

      Heres the links since i finally got a vote
      https://drive.google.com/file/d/1_F2WEZNLCL2GV6dguHE5enHGog8DpD9L/view?usp=sharing
      https://www.virustotal.com/gui/file/e9cec55c4eaeec1195436013149444ff3b7be96558a333c8c161535fd8045f46?nocache=1

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Unread 0
      • Recent
      • Tags
      • Popular
      • Users
      • Groups