diff --git a/MapRestartWorkaround/main.gsc b/MapRestartWorkaround/main.gsc new file mode 100644 index 0000000..38a61ed --- /dev/null +++ b/MapRestartWorkaround/main.gsc @@ -0,0 +1,80 @@ +#include maps\mp\_utility; +#include common_scripts\utility; + +init() +{ + initialMapRestart(); //this only happens once to fix invisible player bug + thread gscRestart(); + thread killAllPlayers(); +} + +initialMapRestart() +{ + if ( getDvarIntDefault( "initial_restart", "1" ) ) + { + wait 15; + setDvar( "initial_restart", "0" ); //dvars persist between map_restarts + map_restart( false ); + } +} + +gscRestart() +{ + while ( 1 ) + { + if ( level.intermission ) + { + wait 20; //20 is ideal + map_restart( false ); + } + wait 1; + } +} + +killAllPlayers() +{ + level.no_end_game_check = 1; //disable end game check just in case player[0] leaves before all players are respawned + level.zombie_vars["penalty_no_revive"] = 0; + wait 3; + players = get_players(); + i = 0; + while ( i < players.size ) + { + if ( i == 0 ) + { + i++; + } + players[ i ] kill(); + i++; + } + wait 5; + spawnAllPlayers(); +} + +kill() +{ + self.maxhealth = 100; + self.health = self.maxhealth; + self disableInvulnerability(); + self dodamage( self.health * 2, self.origin ); + self.bleedout_time = 0; +} + +spawnAllPlayers() +{ + level.zombie_vars["penalty_no_revive"] = 0.1; + players = get_players(); + i = 0; + while ( i < players.size ) + { + if ( players[ i ].sessionstate == "spectator" && isDefined( players[ i ].spectator_respawn ) ) + { + players[ i ] [[ level.spawnplayer ]](); + thread maps\mp\zombies\_zm::refresh_player_navcard_hud(); + players[ i ].score = 500; + players[ i ].downs = 0; //set player downs to 0 since they didn't actually die during gameplay + } + i++; + } + level.no_end_game_check = 0; +} \ No newline at end of file