Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. [Resource] [Zombies] Game Start Delay/Quota Script

[Resource] [Zombies] Game Start Delay/Quota Script

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
12 Posts 8 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JezuzLizardundefined Offline
    JezuzLizardundefined Offline
    JezuzLizard Plutonium Staff
    wrote on last edited by Mr. Android
    #1

    Include these:

    #include maps/mp/_utility;
    #include common_scripts/utility;
    #include maps/mp/gametypes_zm/_hud_util;
    #include maps/mp/gametypes_zm/_hud_message;
    #include maps/mp/zombies/_zm;
    #include maps/mp/zombies/_zm_utility;
    

    Put this in the init():

            level.player_invulernability_active = 1; //set to 0 to disable invulnerability during pregame
    	level.wait_time = 30; //change this to adjust the start time
    	level.player_quota = 2; //change this value to change the player quota I don't recommend values higher than 2
            level.player_quota_active = 1;  //set this to 0 disable player quotas recommended 1 for grief
    	level.waiting = 0; 
    	level.countdown_start = 0;
    	level.round_prestart_func =::round_prestart_func; //delays the rounds from starting
    	SetDvar( "scr_zm_enable_bots", "1" ); //this is required for the mod to work
    	thread add_bots(); //this overrides the typical start game logic
    

    and then put these functions somewhere in your script:

    round_prestart_func() //this function is necessary for certain maps with custom round logic
    {
    	players = get_players();
    	while ( players.size < level.player_quota && level.player_quota_active == 1 || players.size < 1 )
    	{
    		wait 0.5;
    		players = get_players();
    	}	
    	wait level.wait_time;
    }
    
    pregameInvulnerability() //call this in onPlayerSpawned()
    {
    	while ( level.player_invulernability_active == 1 ) //gives all players invulnerability
    	{
    		i = 0;
    		while ( i < players.size )
    		{	
    			players = get_players();
    			wait 0.05;
    			player = players[ i ];
    			player enableinvulnerability();
    			i++;
    		}
    	}
    	while ( level.player_invulernability_active == 0 ) //removes all invulnerability from players
    	{
    		i2 = 0;
    		while ( i2 < players.size )
    		{	
    			players = get_players();
    			wait 0.05;
    			player = players[ i2 ];
    			player disableinvulnerability();
    			i2++;
    		}
    		break;
    	}
    }
    
    add_bots()
    {
        flag_clear( "solo_game" ); //this fixes nuketown by causing the perks to drop like coop and not during the delay
        flag_clear( "start_zombie_round_logic" ); //clears the flag if its up from a map_restart
        players = get_players();
        level.waiting = 1; //set this to 0 to disable the wait message
        thread waitMessage();
        while ( players.size < level.player_quota && level.player_quota_active == 1 || players.size < 1 ) // the OR is there to prevent the timer from starting when the server starts when quotas are disabled
        {
    	  wait 0.5;
              players = get_players();
        }
        level.waiting = 0;
        level.countdown_start = 1; //set this to 0 to disable the countdown message
        thread countdownTimer();
        wait level.wait_time;
        level.player_invulernability_active = 0;
        flag_set( "start_zombie_round_logic" );
    }
    
    waitMessage()
    {   
    	level endon("game_ended");
    	self endon("disconnect");
    	if (  level.player_quota_active == 0 )
    	{
    		return;
    	}
       	Waiting = create_simple_hud();
       	Waiting.horzAlign = "center"; //valid inputs: center, top, bottom, left, right, top_right, top_left, topcenter, bottom_right, bottom_left
       	Waiting.vertAlign = "middle";
       	Waiting.alignX = "center";
       	Waiting.alignY = "middle";
       	Waiting.y = 0; //- is top 0 is middle + is bottom
       	Waiting.x = -1;
       	Waiting.foreground = 1;
       	Waiting.fontscale = 3.0;
       	Waiting.alpha = 1; //transparency
       	Waiting.color = ( 1.000, 1.000, 1.000 ); //RGB
       	Waiting SetText( "Waiting for 1 more player" ); //definitely adjust this text if you do change quota value
       	
       	while ( 1 )
       	{
    		if ( level.waiting == 0 )
    		{
    			Waiting destroy();
    			break;
    		}
    		wait 1;
    	}
    }
    
    countdownTimer()
    {   
    	level endon("game_ended");
    	self endon("disconnect");
    	if (  level.wait_time == 0 )
    	{
    		return;
    	}
    	
    	Remaining = create_simple_hud();
      	Remaining.horzAlign = "center";
      	Remaining.vertAlign = "middle";
       	Remaining.alignX = "Left";
       	Remaining.alignY = "middle";
       	Remaining.y = 0;
       	Remaining.x = 135;
       	Remaining.foreground = 1;
       	Remaining.fontscale = 3.0;
       	Remaining.alpha = 1;
       	Remaining.color = ( 1.000, 1.000, 1.000 );
    
       	Countdown = create_simple_hud();
       	Countdown.horzAlign = "center"; 
       	Countdown.vertAlign = "middle";
       	Countdown.alignX = "center";
       	Countdown.alignY = "middle";
       	Countdown.y = 0;
       	Countdown.x = -1;
       	Countdown.foreground = 1;
       	Countdown.fontscale = 3.0;
       	Countdown.alpha = 1;
       	Countdown.color = ( 1.000, 1.000, 1.000 );
       	Countdown SetText( "Time until game starts:" );
       	
       	timer = level.wait_time;
    	while ( level.countdown_start == 1 )
    	{
    		Remaining SetValue( timer ); 
    		wait 1;
    		timer--;
    		if ( timer <= 0  )
    		{
    			Countdown destroy();
    			Remaining destroy();
    			break;
    		}
    	}
    }
    
    

    Ok so how does this work you ask? Basically there is a function in _zm.gsc called onallplayersready(), and this function is what starts the zombie logic. That function contains an if statement checking if bots are enabled before the standard logic, therefore allowing me to override the typical logic using the add_bots() function.

    This mod may be useful if you want to delay the start of a game allowing players to spawn in at round 1 in your servers.
    I recommend not changing the quota value for public servers since its less likely people will wait for more than 2 players to join a game.

    Please report any bugs you find with this mod on the forum or on my discord JezuzLizard#7864. I will try to fix any bugs as quickly as I can.

    edit: it would appear the mod doesn't work on map_restart since the "zombie_start_round_logic" flag is set from the previous game.
    edit: the above bug is fixed
    edit: updated with pregame invulnerability
    edit: fixed pregame invulnerability now no players will be invulnerable after the game starts
    edit: removed an || condition that was unused in the timer if statement
    edit: added flag_clear( "solo_game" ); to the add_bots() to fix nuketown
    edit: added if statements checking if waitMessage() and countdownTimer() should end immediately if they shouldn't be active

    1 Reply Last reply
    0
    • luigistyleundefined Offline
      luigistyleundefined Offline
      luigistyle Plutonium Staff
      wrote on last edited by
      #2

      Haven't tried it out yet (not something I'd use tbh because most of this community is too stupid to be able to wait) but thx for contribution OP!

      1 Reply Last reply
      0
      • Ox_undefined Offline
        Ox_undefined Offline
        Ox_
        wrote on last edited by
        #3

        Seems like good stuff.
        Btw, are you sure you don't break Mob of the Dead by overriding level.round_prestart_func?
        That map has custom logic in that function.

        JezuzLizardundefined 1 Reply Last reply
        0
        • JezuzLizardundefined Offline
          JezuzLizardundefined Offline
          JezuzLizard Plutonium Staff
          replied to Ox_ on last edited by
          #4

          Ox_ It doesn't break MoTD to be exact it just starts the game when the player quota is met or the timer counts down instead of waiting for players to revive themselves. You still get your afterlife if you're alive when the round actually begins though. I tried to see if I could add an exception to MoTD where it waits for players to revive themselves then the game starts but I couldn't wait the add_bots() with a condition that it would actually use.

          1 Reply Last reply
          0
          • Mr. Androidundefined Offline
            Mr. Androidundefined Offline
            Mr. Android Plutonium Admin
            wrote on last edited by
            #5

            Nice release OP 🙂 Keep it up!

            1 Reply Last reply
            1
            • LuqyAFundefined Offline
              LuqyAFundefined Offline
              LuqyAF
              wrote on last edited by
              #6

              When I try to compile the script it says that it is bad syntax at line 219 which in my .gsc is timer--;

              Any help is appreciated

              JezuzLizardundefined 1 Reply Last reply
              0
              • JezuzLizardundefined Offline
                JezuzLizardundefined Offline
                JezuzLizard Plutonium Staff
                replied to LuqyAF on last edited by
                #7

                LuqyAF I removed the || condition from the line:
                if ( timer <= 0 || )
                thats why it was throwing a syntax error sorry my bad.

                Theres another bug in the meantime I'm working on fixing on Nuketown where quick revive doesn't get powered on after the game starts.

                1 Reply Last reply
                0
                • xJiroZomber935xundefined Offline
                  xJiroZomber935xundefined Offline
                  xJiroZomber935x
                  wrote on last edited by xJiroZomber935x
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • PootOSundefined Offline
                    PootOSundefined Offline
                    PootOS
                    wrote on last edited by
                    #9

                    Hey I needed some help with this, ive figured out where to put the init stuff and the actual functions themselves, but with the little documentation I haven't been able to figure out where to put the #include statements.

                    I'm brand new to this and just wanted to setup a server with scripts to make it a little bit more fun but have been having trouble.

                    Any help is appreciated!

                    luigistyleundefined 1 Reply Last reply
                    0
                    • Acrillxundefined Offline
                      Acrillxundefined Offline
                      Acrillx
                      wrote on last edited by
                      #10

                      PootOS please just make a new forum no need to revive a old post

                      1 Reply Last reply
                      0
                      • luigistyleundefined Offline
                        luigistyleundefined Offline
                        luigistyle Plutonium Staff
                        replied to PootOS on last edited by
                        #11

                        PootOS This mod has little purpose now that zombies_minplayers has been implemented, I suggest you use that instead.

                        PootOSundefined 1 Reply Last reply
                        1
                        • PootOSundefined Offline
                          PootOSundefined Offline
                          PootOS
                          replied to luigistyle on last edited by
                          #12

                          luigistyle I did look up the zombies_minplayers and that has solved my problem with the late join thing, thank you.

                          I would still appreciate it though if I could be told where the init would go. I was trying some other scripts around the same time as this first one and I figured out where everything went except for the init.

                          1 Reply Last reply
                          0

                          • Login

                          • Don't have an account? Register

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