[Resource] [Zombies] Game Start Delay/Quota Script
-
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 -
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!
-
Seems like good stuff.
Btw, are you sure you don't break Mob of the Dead by overridinglevel.round_prestart_func
?
That map has custom logic in that function. -
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.
-
Nice release OP Keep it up!
-
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
-
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.
-
This post is deleted!
-
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!
-
PootOS please just make a new forum no need to revive a old post
-
PootOS This mod has little purpose now that
zombies_minplayers
has been implemented, I suggest you use that instead. -
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.