class SchlonzVotingHandler extends VotingHandler config; // work variables var array MVRI; // used to communicated between players and server var int TimeLeft; var string ServerTravelString; var int CountPlayers; var string SchlonzVoteIP; var int SchlonzVotePort; var() config int VoteTimeLimit; //------------------------------------------------------------------------------------------------ static function bool IsEnabled() { return true; } event PreBeginPlay() { log ("___SchlonzVotingHandler PreBeginPlay " ); Super.PreBeginPlay(); CountPlayers = 0; } // PreBeginPlay function PlayerJoin(PlayerController Player) { if(!Player.IsA('XPlayer')) // no bots return; if( SchlonzControllerPlayer( Player ) != None ) { MVRI[MVRI.Length] = SchlonzControllerPlayer( Player ); CountPlayers++; log ("___PlayerJoined " ); } } // PlayerJoin function PlayerExit(Controller Exiting) { local int i; if( SchlonzControllerPlayer( Exiting ) == None ) return; // find the MVRI belonging to the exiting player for(i=0;i < MVRI.Length;i++) { // remove players vote from vote count if( MVRI[i] != none ) { if( MVRI[i] == SchlonzControllerPlayer( Exiting ) ) { MVRI[i] = none; CountPlayers--; log ("___Playerv Left " ); break; } } } } // PlayerExit function bool HandleRestartGame() { TimeLeft = VoteTimeLimit; SetTimer( 1,true ); log ("___OpenAllVoteWindows " ); OpenAllVoteWindows(); return false; } // HandleRestartGame event timer() { local int i, c; local SchlonzUdpLink mysock; local string LastLevel; local GameStats gs; TimeLeft--; log ("___Timer Expires " $ TimeLeft ); // check if all player voted... c = 0; for( i=0 ; i < MVRI.Length ; i++) { if(MVRI[i] != none) { SchlonzVoteIP = MVRI[i].SchlonzVoteIP; SchlonzVotePort = MVRI[i].SchlonzVotePort; if( MVRI[i].HasVoted || MVRI[i].CancelAlways) { if( LastLevel == "" ) { gs = MVRI[i].Spawn( class'GameStats' ); LastLevel = gs.GetMapFileName(); gs.Destroy(); } c++; } } } if( c == CountPlayers ) TimeLeft = 0; if( TimeLeft == 0 ) { SetTimer(0.0, False); CloseAllVoteWindows(); mysock = Spawn( class'SchlonzUT.SchlonzUdpLink' ); if( mysock != None ) { log( "__mysock spawned" ); mysock.setIpPort( SchlonzVoteIP, SchlonzVotePort ); mysock.bindNextAvail(); mysock.NextLevel( Level, LastLevel ); } //ServerTravelString = "ONS-Dria.ut2?Onslaught.ONSOnslaughtGame"; //Level.ServerTravel(ServerTravelString, false); // change the map } } // timer function OpenAllVoteWindows() { local int i; for( i=0 ; i < MVRI.Length ; i++ ) { if( MVRI[i] != none ) { log( "Opening window "); MVRI[i].OpenWindow(); } } } // OpenAllVoteWindows function CloseAllVoteWindows() { local int i; for(i=0; i < MVRI.Length;i++) { if(MVRI[i] != none) { log("___Closing window "); MVRI[i].CloseWindow(); } } } // CloseAllVoteWindows defaultproperties { VoteTimeLimit=120 }