2009-04-18 01:44:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-18 01:44:41 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: roundend.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Handles round end actions.
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-12 05:51:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-18 01:44:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
2019-08-19 15:26:37 +02:00
|
|
|
#if defined REQUIRE_EXTENSIONS
|
|
|
|
#define TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#undef REQUIRE_EXTENSIONS
|
2017-05-01 23:59:38 +02:00
|
|
|
#endif
|
|
|
|
|
2019-08-19 15:12:15 +02:00
|
|
|
#tryinclude "sourcetvmanager.inc"
|
2017-05-01 23:59:38 +02:00
|
|
|
|
|
|
|
/* Restore old REQUIRE_EXTENSIONS value if necessary */
|
|
|
|
#if defined TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#define REQUIRE_EXTENSIONS
|
|
|
|
#undef TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#endif
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* @section All round end reasons.
|
|
|
|
*/
|
2010-06-25 04:51:01 +02:00
|
|
|
#define ROUNDEND_TARGET_BOMBED 0 // Target Successfully Bombed!
|
|
|
|
#define ROUNDEND_VIP_ESCAPED 1 // The VIP has escaped!
|
|
|
|
#define ROUNDEND_VIP_ASSASSINATED 2 // VIP has been assassinated!
|
|
|
|
#define ROUNDEND_TERRORISTS_ESCAPED 3 // The terrorists have escaped!
|
|
|
|
#define ROUNDEND_CTS_PREVENTESCAPE 4 // The CT's have prevented most of the terrorists from escaping!
|
|
|
|
#define ROUNDEND_ESCAPING_TERRORISTS_NEUTRALIZED 5 // Escaping terrorists have all been neutralized!
|
|
|
|
#define ROUNDEND_BOMB_DEFUSED 6 // The bomb has been defused!
|
|
|
|
#define ROUNDEND_CTS_WIN 7 // Counter-Terrorists Win!
|
|
|
|
#define ROUNDEND_TERRORISTS_WIN 8 // Terrorists Win!
|
|
|
|
#define ROUNDEND_ROUND_DRAW 9 // Round Draw!
|
|
|
|
#define ROUNDEND_ALL_HOSTAGES_RESCUED 10 // All Hostages have been rescued!
|
|
|
|
#define ROUNDEND_TARGET_SAVED 11 // Target has been saved!
|
|
|
|
#define ROUNDEND_HOSTAGES_NOT_RESCUED 12 // Hostages have not been rescued!
|
|
|
|
#define ROUNDEND_TERRORISTS_NOT_ESCAPED 13 // Terrorists have not escaped!
|
|
|
|
#define ROUNDEND_VIP_NOT_ESCAPED 14 // VIP has not escaped!
|
|
|
|
#define ROUNDEND_GAME_COMMENCING 15 // Game Commencing!
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* @endsection
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delay between round ending and new round starting. (Normal)
|
|
|
|
*/
|
2009-04-29 01:58:41 +02:00
|
|
|
#define ROUNDEND_DELAY 5.0
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* Possible round end outcomes.
|
|
|
|
*/
|
|
|
|
enum RoundEndOutcome
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
Restart, /** Round is restarting. */
|
|
|
|
Draw, /** Round has ended in unexpected way. */
|
2009-04-27 04:00:38 +02:00
|
|
|
HumansWin, /** Humans have killed all zombies. */
|
|
|
|
ZombiesWin, /** Zombies have infected all humans. */
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Global variable to store round win timer handle.
|
|
|
|
*/
|
2017-01-22 15:09:22 +01:00
|
|
|
new Handle:g_tRoundEnd = INVALID_HANDLE;
|
2009-04-18 01:44:41 +02:00
|
|
|
|
2017-05-01 23:59:38 +02:00
|
|
|
new bool:g_SourceTVManagerLoaded = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* All plugins have finished loading.
|
|
|
|
*/
|
|
|
|
RoundEndOnAllPluginsLoaded()
|
|
|
|
{
|
|
|
|
#if defined _stvmngr_included
|
|
|
|
g_SourceTVManagerLoaded = LibraryExists("sourcetvmanager");
|
|
|
|
LogMessage("SourceTV Manager: %s", (g_SourceTVManagerLoaded ? "loaded" : "not loaded"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* Map is starting.
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-04-18 01:44:41 +02:00
|
|
|
RoundEndOnMapStart()
|
|
|
|
{
|
|
|
|
// Reset timer handle.
|
2017-01-22 15:09:22 +01:00
|
|
|
g_tRoundEnd = INVALID_HANDLE;
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
|
2009-04-22 04:53:19 +02:00
|
|
|
/**
|
|
|
|
* Client has been killed.
|
|
|
|
*/
|
|
|
|
RoundEndOnClientDeath()
|
2009-04-27 04:00:38 +02:00
|
|
|
{
|
|
|
|
// Terminate the round if the last player was killed.
|
|
|
|
new RoundEndOutcome:outcome;
|
|
|
|
if (RoundEndGetRoundStatus(outcome))
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
RoundEndTerminateRound(ROUNDEND_DELAY, outcome);
|
2009-04-27 04:00:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client has been infected.
|
|
|
|
*/
|
|
|
|
RoundEndOnClientInfected()
|
2009-04-22 04:53:19 +02:00
|
|
|
{
|
|
|
|
// Terminate the round if the last player was infected.
|
|
|
|
new RoundEndOutcome:outcome;
|
|
|
|
if (RoundEndGetRoundStatus(outcome))
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
RoundEndTerminateRound(ROUNDEND_DELAY, outcome);
|
2009-04-22 04:53:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* The round is starting.
|
|
|
|
*/
|
|
|
|
RoundEndOnRoundStart()
|
|
|
|
{
|
2009-06-21 23:59:18 +02:00
|
|
|
// Stop all overlays.
|
|
|
|
RoundEndOverlayStop();
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// If round end timer is running, then kill it.
|
2017-01-22 15:09:22 +01:00
|
|
|
if (g_tRoundEnd != INVALID_HANDLE)
|
2009-04-18 01:44:41 +02:00
|
|
|
{
|
|
|
|
// Kill timer.
|
2017-01-22 15:09:22 +01:00
|
|
|
KillTimer(g_tRoundEnd);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Reset timer handle.
|
2017-01-22 15:09:22 +01:00
|
|
|
g_tRoundEnd = INVALID_HANDLE;
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The freeze time is ending.
|
|
|
|
*/
|
|
|
|
RoundEndOnRoundFreezeEnd()
|
|
|
|
{
|
|
|
|
// Calculate round length, in seconds.
|
|
|
|
// Get mp_roundtime. (in minutes)
|
|
|
|
new Float:roundtime = GetConVarFloat(FindConVar("mp_roundtime"));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Convert to seconds.
|
|
|
|
roundtime *= 60.0;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2013-01-10 09:09:25 +01:00
|
|
|
// Subtract one second if running CS: GO to prevent round draw when round
|
|
|
|
// ends. For some reason the timing doesn't match the actual round end.
|
|
|
|
// Thanks to Jargon.
|
|
|
|
if (g_Game == Game_CSGO)
|
|
|
|
{
|
|
|
|
roundtime--;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Start timer.
|
2017-01-22 15:09:22 +01:00
|
|
|
g_tRoundEnd = CreateTimer(roundtime, RoundEndTimer, _, TIMER_FLAG_NO_MAPCHANGE);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The round is ending.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-18 01:44:41 +02:00
|
|
|
* @param reason Reason the round has ended.
|
|
|
|
*/
|
|
|
|
RoundEndOnRoundEnd(reason)
|
|
|
|
{
|
|
|
|
// If round end timer is running, then kill it.
|
2017-01-22 15:09:22 +01:00
|
|
|
if (g_tRoundEnd != INVALID_HANDLE)
|
2009-04-18 01:44:41 +02:00
|
|
|
{
|
|
|
|
// Kill timer.
|
2017-01-22 15:09:22 +01:00
|
|
|
KillTimer(g_tRoundEnd);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Reset timer handle.
|
2017-01-22 15:09:22 +01:00
|
|
|
g_tRoundEnd = INVALID_HANDLE;
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-22 04:53:19 +02:00
|
|
|
// Tell plugin no zombies have been spawned.
|
|
|
|
g_bZombieSpawned = false;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Get outcome of the round.
|
|
|
|
new RoundEndOutcome:outcome = RoundEndReasonToOutcome(reason);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-27 21:17:34 +02:00
|
|
|
// Update team scores.
|
|
|
|
new teamscore;
|
|
|
|
switch(outcome)
|
|
|
|
{
|
|
|
|
// Zombies won the round.
|
|
|
|
case ZombiesWin:
|
|
|
|
{
|
|
|
|
// Increment T score.
|
|
|
|
teamscore = GetTeamScore(CS_TEAM_T);
|
|
|
|
SetTeamScore(CS_TEAM_T, ++teamscore);
|
|
|
|
}
|
|
|
|
// Humans won the round.
|
|
|
|
case HumansWin:
|
|
|
|
{
|
|
|
|
// Increment CT score.
|
|
|
|
teamscore = GetTeamScore(CS_TEAM_CT);
|
|
|
|
SetTeamScore(CS_TEAM_CT, ++teamscore);
|
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Display the overlay to all clients.
|
2009-06-21 23:59:18 +02:00
|
|
|
RoundEndOverlayStart(outcome);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2017-01-22 15:09:22 +01:00
|
|
|
RoundEndDisplayStats();
|
|
|
|
|
2013-11-11 01:03:23 +01:00
|
|
|
// Balance teams if enabled.
|
|
|
|
if (GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_BALANCE_TEAMS]))
|
|
|
|
{
|
|
|
|
RoundEndBalanceTeams();
|
|
|
|
}
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
|
2017-01-22 15:09:22 +01:00
|
|
|
RoundEndDisplayStats()
|
|
|
|
{
|
|
|
|
for(int player = 1; player <= MaxClients; player++)
|
|
|
|
{
|
|
|
|
if(!IsClientInGame(player))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
static char sPlayerID[8];
|
|
|
|
static char sPlayerName[MAX_NAME_LENGTH + 2];
|
|
|
|
static char sPlayerAuth[24];
|
|
|
|
static char sPlayerTeam[8];
|
|
|
|
static char sPlayerState[8];
|
|
|
|
|
|
|
|
FormatEx(sPlayerID, sizeof(sPlayerID), "%d", GetClientUserId(player));
|
|
|
|
FormatEx(sPlayerName, sizeof(sPlayerName), "\"%N\"", player);
|
|
|
|
|
|
|
|
if(!GetClientAuthId(player, AuthId_Steam2, sPlayerAuth, sizeof(sPlayerAuth)))
|
|
|
|
FormatEx(sPlayerAuth, sizeof(sPlayerAuth), "STEAM_ID_PENDING");
|
|
|
|
|
|
|
|
if(IsPlayerAlive(player))
|
|
|
|
FormatEx(sPlayerState, sizeof(sPlayerState), "alive");
|
|
|
|
else
|
|
|
|
FormatEx(sPlayerState, sizeof(sPlayerState), "dead");
|
|
|
|
|
|
|
|
if(InfectIsClientInfected(player))
|
|
|
|
FormatEx(sPlayerTeam, sizeof(sPlayerTeam), "zombie");
|
|
|
|
else
|
|
|
|
FormatEx(sPlayerTeam, sizeof(sPlayerTeam), "human");
|
|
|
|
|
|
|
|
for(int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
|
|
|
if(!IsClientInGame(client))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
PrintToConsole(client, "# %8s %40s %24s %5s %6s",
|
|
|
|
sPlayerID, sPlayerName, sPlayerAuth, sPlayerState, sPlayerTeam);
|
|
|
|
}
|
2017-05-01 23:59:38 +02:00
|
|
|
|
|
|
|
#if defined _stvmngr_included
|
|
|
|
if(g_SourceTVManagerLoaded)
|
|
|
|
{
|
|
|
|
SourceTV_PrintToDemoConsole("# %8s %40s %24s %5s %6s",
|
|
|
|
sPlayerID, sPlayerName, sPlayerAuth, sPlayerState, sPlayerTeam);
|
|
|
|
}
|
|
|
|
#endif
|
2017-01-22 15:09:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* Convert a round_end reason, to a round winner, or draw.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-18 01:44:41 +02:00
|
|
|
* @param reason The round_end reason.
|
|
|
|
* @return The winner of the round. (see enum RoundEndOutcome)
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-04-18 01:44:41 +02:00
|
|
|
RoundEndOutcome:RoundEndReasonToOutcome(reason)
|
|
|
|
{
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
// CTs won the round.
|
|
|
|
case ROUNDEND_CTS_WIN:
|
|
|
|
{
|
|
|
|
return HumansWin;
|
|
|
|
}
|
|
|
|
// Ts won the round.
|
|
|
|
case ROUNDEND_TERRORISTS_WIN:
|
|
|
|
{
|
|
|
|
return ZombiesWin;
|
|
|
|
}
|
|
|
|
// Unexpected case.
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
return Draw;
|
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Return draw to satisfy compiler. (code will never reach this point.)
|
|
|
|
return Draw;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timer callback, called when round time reaches 0.
|
|
|
|
*
|
|
|
|
* @param timer The timer handle.
|
|
|
|
*/
|
|
|
|
public Action:RoundEndTimer(Handle:timer)
|
|
|
|
{
|
2009-06-22 22:07:19 +02:00
|
|
|
// Set the global timer handle variable to INVALID_HANDLE.
|
2017-01-22 15:09:22 +01:00
|
|
|
g_tRoundEnd = INVALID_HANDLE;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-30 07:36:57 +02:00
|
|
|
// If there aren't clients on both teams, then stop.
|
2009-05-01 07:09:18 +02:00
|
|
|
if (!ZRTeamHasClients())
|
2009-04-30 07:36:57 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2018-07-22 16:14:39 +02:00
|
|
|
new bool:zombies_win = GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_ZOMBIES_WIN]);
|
|
|
|
if (zombies_win)
|
2018-07-22 16:25:36 +02:00
|
|
|
RoundEndTerminateRound(ROUNDEND_DELAY, ZombiesWin);
|
|
|
|
else
|
|
|
|
RoundEndTerminateRound(ROUNDEND_DELAY, HumansWin);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the round is over.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-18 01:44:41 +02:00
|
|
|
* @param outcome Set to the outcome of the round, if round is over.
|
|
|
|
* @return True if the round is over, false otherwise.
|
|
|
|
*/
|
|
|
|
bool:RoundEndGetRoundStatus(&RoundEndOutcome:outcome)
|
|
|
|
{
|
|
|
|
// If zombie hasn't spawned, then stop.
|
2015-03-22 18:06:40 +01:00
|
|
|
if (!InfectHasZombieSpawned())
|
2009-04-18 01:44:41 +02:00
|
|
|
{
|
|
|
|
// Round isn't over.
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Initialize count variables
|
|
|
|
new zombiecount;
|
|
|
|
new humancount;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Count valid clients. (true to only allow living clients)
|
2009-06-19 00:53:22 +02:00
|
|
|
ZRCountValidClients(zombiecount, humancount, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// If there are no clients on either teams, then stop.
|
|
|
|
if (!zombiecount && !humancount)
|
|
|
|
{
|
|
|
|
// Round isn't active.
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// If there are clients on both teams, then stop.
|
|
|
|
if (zombiecount && humancount)
|
|
|
|
{
|
|
|
|
// Round isn't over.
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// We know here, that either zombiecount or humancount is 0. (not both)
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// If there are zombies, then zombies won the round.
|
|
|
|
if (zombiecount)
|
|
|
|
{
|
|
|
|
outcome = ZombiesWin;
|
|
|
|
}
|
|
|
|
// If there are no zombies, that means there must be humans, they win the round.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outcome = HumansWin;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// Round is over.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-04-29 01:58:41 +02:00
|
|
|
* Ends the round with the given outcome and delay.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
|
|
|
* @param delay Delay before new round starts.
|
2009-04-18 01:44:41 +02:00
|
|
|
* @param outcome The outcome of the round.
|
|
|
|
*/
|
2009-04-29 01:58:41 +02:00
|
|
|
RoundEndTerminateRound(Float:delay, RoundEndOutcome:outcome = Restart)
|
2009-04-18 01:44:41 +02:00
|
|
|
{
|
|
|
|
switch(outcome)
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Round is restarting.
|
|
|
|
case Restart:
|
|
|
|
{
|
2012-01-28 19:12:33 +01:00
|
|
|
CS_TerminateRound(delay, CSRoundEnd_GameStart, false);
|
2009-04-29 01:58:41 +02:00
|
|
|
}
|
|
|
|
// Round was a draw.
|
|
|
|
case Draw:
|
|
|
|
{
|
2012-01-28 19:12:33 +01:00
|
|
|
CS_TerminateRound(delay, CSRoundEnd_Draw, false);
|
2009-04-29 01:58:41 +02:00
|
|
|
}
|
2009-04-18 01:44:41 +02:00
|
|
|
// Zombies won.
|
|
|
|
case ZombiesWin:
|
|
|
|
{
|
2012-01-28 19:12:33 +01:00
|
|
|
CS_TerminateRound(delay, CSRoundEnd_TerroristWin, false);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
// Humans won.
|
|
|
|
case HumansWin:
|
|
|
|
{
|
2012-01-28 19:12:33 +01:00
|
|
|
CS_TerminateRound(delay, CSRoundEnd_CTWin, false);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
/**
|
2011-12-27 09:05:27 +01:00
|
|
|
* Balances teams.
|
2009-04-19 19:54:21 +02:00
|
|
|
*/
|
2009-04-27 04:00:38 +02:00
|
|
|
RoundEndBalanceTeams()
|
2009-04-19 19:54:21 +02:00
|
|
|
{
|
|
|
|
// Create eligible player list.
|
|
|
|
new Handle:arrayEligibleClients = INVALID_HANDLE;
|
2009-04-22 04:53:19 +02:00
|
|
|
new eligibleclients = ZRCreateEligibleClientList(arrayEligibleClients, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// If there are no eligible client's then stop.
|
|
|
|
if (!eligibleclients)
|
|
|
|
{
|
2009-07-24 02:05:04 +02:00
|
|
|
// Destroy handle.
|
|
|
|
CloseHandle(arrayEligibleClients);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
new client;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Move all clients to T
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// x = Array index.
|
2009-04-19 19:54:21 +02:00
|
|
|
// client = client index.
|
|
|
|
for (new x = 0; x < eligibleclients; x++)
|
|
|
|
{
|
|
|
|
// Get client stored in array index.
|
|
|
|
client = GetArrayCell(arrayEligibleClients, x);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Switch client to T
|
|
|
|
CS_SwitchTeam(client, CS_TEAM_T);
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Move every other client back to CT
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// x = array index
|
|
|
|
// client = client index.
|
|
|
|
for (new x = 0; x < eligibleclients; x += 2)
|
|
|
|
{
|
|
|
|
// Get client stored in array index.
|
|
|
|
client = GetArrayCell(arrayEligibleClients, x);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-19 19:54:21 +02:00
|
|
|
// Switch client to CT
|
|
|
|
CS_SwitchTeam(client, CS_TEAM_CT);
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-21 03:10:14 +02:00
|
|
|
// Destroy handle.
|
|
|
|
CloseHandle(arrayEligibleClients);
|
2009-04-19 19:54:21 +02:00
|
|
|
}
|
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
/**
|
|
|
|
* Displays overlays to clients, depending on the outcome.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-18 01:44:41 +02:00
|
|
|
* @param time Time to display overlays.
|
|
|
|
* @param outcome The outcome of the round.
|
|
|
|
*/
|
2009-06-21 23:59:18 +02:00
|
|
|
RoundEndOverlayStart(RoundEndOutcome:outcome)
|
2009-04-18 01:44:41 +02:00
|
|
|
{
|
|
|
|
// If round end overlays are disabled, then stop.
|
2009-04-20 02:56:26 +02:00
|
|
|
new bool:overlay = GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_OVERLAY]);
|
2009-04-18 01:44:41 +02:00
|
|
|
if (!overlay)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
decl String:overlaypath[PLATFORM_MAX_PATH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
switch(outcome)
|
|
|
|
{
|
|
|
|
// Show "zombies win" overlay.
|
|
|
|
case ZombiesWin:
|
|
|
|
{
|
2009-04-20 02:56:26 +02:00
|
|
|
GetConVarString(g_hCvarsList[CVAR_ROUNDEND_OVERLAY_ZOMBIE], overlaypath, sizeof(overlaypath));
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
// Show "humans win" overlay.
|
|
|
|
case HumansWin:
|
|
|
|
{
|
2009-04-20 02:56:26 +02:00
|
|
|
GetConVarString(g_hCvarsList[CVAR_ROUNDEND_OVERLAY_HUMAN], overlaypath, sizeof(overlaypath));
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
// Show no overlay.
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
strcopy(overlaypath, sizeof(overlaypath), "");
|
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-18 01:44:41 +02:00
|
|
|
// x = client index.
|
|
|
|
for (new x = 1; x <= MaxClients; x++)
|
|
|
|
{
|
|
|
|
// If client isn't in-game, then stop.
|
|
|
|
if (!IsClientInGame(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// If client is fake (or bot), then stop.
|
|
|
|
if (IsFakeClient(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
OverlaysClientSetChannelPath(x, OVERLAYS_CHANNEL_ROUNDEND, overlaypath);
|
|
|
|
OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, true);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RoundEndOverlayStop()
|
|
|
|
{
|
|
|
|
// x = client index.
|
|
|
|
for (new x = 1; x <= MaxClients; x++)
|
|
|
|
{
|
|
|
|
// If client isn't in-game, then stop.
|
|
|
|
if (!IsClientInGame(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// If client is fake (or bot), then stop.
|
|
|
|
if (IsFakeClient(x))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-14 02:28:26 +02:00
|
|
|
// Disable roundend overlay channel.
|
|
|
|
OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, false, true);
|
2009-04-18 01:44:41 +02:00
|
|
|
}
|
2009-06-21 23:59:18 +02:00
|
|
|
}
|