Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void IGameController::DoPlayerNumWincheck()
- {
- if(m_GameOverTick != -1 || m_Warmup)
- return;
- // get winning team
- int FirstFoundTeam = -1;
- int NumPlayers = 0;
- bool MoreThanOneTeam = false;
- // gather some stats
- int Topscore = 0;
- int TopscoreCount = 0;
- int TopID = -1;
- for(int i = 0; i < MAX_CLIENTS; i++)
- {
- if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() > -1)
- {
- NumPlayers++;
- if(GameServer()->m_apPlayers[i]->m_Score > Topscore)
- {
- Topscore = GameServer()->m_apPlayers[i]->m_Score;
- TopscoreCount = 1;
- TopID = i;
- }
- else if(GameServer()->m_apPlayers[i]->m_Score == Topscore)
- TopscoreCount++;
- }
- else
- continue;
- if(FirstFoundTeam < 0)
- {
- FirstFoundTeam = GameServer()->m_apPlayers[i]->m_CatchingTeam;
- continue;
- }
- // if more than 1 team ingame dont end round
- if(GameServer()->m_apPlayers[i]->m_CatchingTeam != FirstFoundTeam)
- MoreThanOneTeam = true;
- }
- // check score win condition
- if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
- (g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
- {
- if(TopscoreCount == 1)
- {
- char buf[1024];
- str_format(buf, sizeof(buf), "%s won the game. A new round start", Server()->ClientName(TopID));
- GameServer()->SendBroadcast(buf, -1);
- GameServer()->SendChatTarget(-1, buf);
- m_RoundRestart = true;
- EndRound();
- }
- else
- m_SuddenDeath = 1;
- }
- // get the winner
- if(NumPlayers > 1 && !MoreThanOneTeam)
- {
- int Winner = -1;
- for(int i = 0; i < MAX_CLIENTS; i++)
- if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_BaseCatchingTeam == FirstFoundTeam)
- Winner = i;
- if(Winner > -1)
- {
- char buf[1024];
- str_format(buf, sizeof(buf), "%s's Team wins", Server()->ClientName(Winner));
- GameServer()->SendBroadcast(buf, -1);
- GameServer()->SendChatTarget(-1, buf);
- GameServer()->m_apPlayers[Winner]->m_Score += g_Config.m_SvScoreIncrease;
- EndRound();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement