void CHL2MPRules::RestartGame() { // bounds check if ( mp_timelimit.GetInt() < 0 ) { mp_timelimit.SetValue( 0 ); } m_flGameStartTime = gpGlobals->curtime; if ( !IsFinite( m_flGameStartTime.Get() ) ) { Warning( "Trying to set a NaN game start time\n" ); m_flGameStartTime.GetForModify() = 0.0f; } CleanUpMap(); // now respawn all players for (int i = 1; i <= gpGlobals->maxClients; i++ ) { CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); if ( !pPlayer ) continue; if ( pPlayer->GetActiveWeapon() ) { pPlayer->GetActiveWeapon()->Holster(); } pPlayer->RemoveAllItems( true ); respawn( pPlayer, false ); pPlayer->Reset(); } // Respawn entities (glass, doors, etc..) CTeam *pRebels = GetGlobalTeam( TEAM_REBELS ); CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE ); if ( pRebels ) { pRebels->SetScore( 0 ); } if ( pCombine ) { pCombine->SetScore( 0 ); } m_flIntermissionEndTime = 0; m_flRestartGameTime = 0.0; m_bCompleteReset = false; IGameEvent * event = gameeventmanager->CreateEvent( "round_start" ); if ( event ) { event->SetInt("fraglimit", 0 ); event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted event->SetString("objective","DEATHMATCH"); gameeventmanager->FireEvent( event ); } }
void CHL2MPRules::RestartGame() { // bounds check if ( mp_timelimit.GetInt() < 0 ) { mp_timelimit.SetValue( 0 ); } m_flGameStartTime = gpGlobals->curtime; if ( !IsFinite( m_flGameStartTime.Get() ) ) { Warning( "Trying to set a NaN game start time\n" ); m_flGameStartTime.GetForModify() = 0.0f; } // Pre Map Cleanup for (int i = 1; i <= gpGlobals->maxClients; i++ ) { CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); if ( !pPlayer ) continue; //Tony; if they aren't a spectator, make sure they get cleaned up before entities are removed! if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR ) { // If they're in a vehicle, make sure they get out! if ( pPlayer->IsInAVehicle() ) pPlayer->LeaveVehicle(); QAngle angles = pPlayer->GetLocalAngles(); angles.x = 0; angles.z = 0; pPlayer->SetLocalAngles( angles ); CBaseCombatWeapon *pWeapon = (CBaseCombatWeapon*)pPlayer->GetActiveWeapon(); if (pWeapon) { pPlayer->Weapon_Detach( pWeapon ); UTIL_Remove( pWeapon ); } } pPlayer->RemoveAllItems(true); pPlayer->ClearActiveWeapon(); pPlayer->Reset(); } CleanUpMap(); // now that everything is cleaned up, respawn everyone. for (int i = 1; i <= gpGlobals->maxClients; i++ ) { CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); if ( !pPlayer ) continue; //Tony; if they aren't a spectator, respawn them. if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR ) pPlayer->Spawn(); } CTeam *pRebels = GetGlobalTeam( TEAM_REBELS ); CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE ); if ( pRebels ) { pRebels->SetRoundScore( 0 ); } if ( pCombine ) { pCombine->SetRoundScore( 0 ); } m_flIntermissionEndTime = 0; m_flRestartGameTime = 0.0; m_bCompleteReset = false; IGameEvent * event = gameeventmanager->CreateEvent( "round_start" ); if ( event ) { event->SetInt("fraglimit", 0 ); event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted event->SetString("objective","DEATHMATCH"); gameeventmanager->FireEvent( event ); } }