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

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. I wanted to add a timer to know how long it took the player to take the round

I wanted to add a timer to know how long it took the player to take the round

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
1 Posts 1 Posters 166 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.
  • _pro7undefined Offline
    _pro7undefined Offline
    _pro7
    wrote on last edited by
    #1
    high_round_tracker()
    {
    	// marca que está rodando (debug opcional)
    	// iprintlnbold("^2HighRound Tracker ON");
    
    	// thread que informa recordes periodicamente
    	thread high_round_info_giver();
    
    	// Descobre mapa/modo
    	gamemode = gamemodeName(getDvar("ui_gametype"));
    	map = mapName(level.script);
    	if (level.script == "zm_transit" && getDvar("ui_gametype") == "zsurvival")
    	{
    		map = startLocationName(getDvar("ui_zm_mapstartlocation"));
    	}
    
    	// Garante pasta de logs
    	if (!directoryExists("logs"))
    	{
    		createDirectory("logs");
    	}
    
    	filename = "logs/" + map + gamemode + "HighRound.txt";
    
    	// Inicializa arquivo se não existir
    	if (!fileExists(filename))
    	{
    		writeFile(filename, "0;-", false); // false = sobrescreve
    	}
    
    	// Carrega estado
    	text = readFile(filename);
    	if (!isDefined(text) || text == "")
    	{
    		text = "0;-";
    	}
    
    	info = strTok(text, ";");
    	level.HighRound = int(info[0]);
    	level.HighRoundPlayers = isDefined(info[1]) ? info[1] : "-";
    
    	// Espera fim da partida para checar recorde
    	for (;;)
    	{
    		level waittill("end_game");
    
    		if (level.round_number > level.HighRound)
    		{
    			// monta lista de jogadores
    			level.HighRoundPlayers = "";
    			players = get_players();
    			for (i = 0; i < players.size; i++)
    			{
    				if (level.HighRoundPlayers == "")
    					level.HighRoundPlayers = players[i].name;
    				else
    					level.HighRoundPlayers = level.HighRoundPlayers + "," + players[i].name;
    			}
    
    			// feedback
    			foreach (player in level.players)
    			{
    				player tell("Record: ^1" + level.round_number);
    				player tell("Por: ^1" + level.HighRoundPlayers);
    			}
    
    			// persiste no disco e atualiza variáveis
    			log_highround_record(level.round_number + ";" + level.HighRoundPlayers);
    		}
    	}
    }
    
    log_highround_record(newRecord)
    {
    	gamemode = gamemodeName(getDvar("ui_gametype"));
    	map = mapName(level.script);
    	if (level.script == "zm_transit" && getDvar("ui_gametype") == "zsurvival")
    	{
    		map = startLocationName(getDvar("ui_zm_mapstartlocation"));
    	}
    
    	filename = "logs/" + map + gamemode + "HighRound.txt";
    	writeFile(filename, newRecord, false); // sobrescreve com o novo recorde
    
    	// Atualiza na memória
    	info = strTok(newRecord, ";");
    	level.HighRound = int(info[0]);
    	level.HighRoundPlayers = isDefined(info[1]) ? info[1] : "-";
    }
    
    1 Reply Last reply
    1

    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