Skip to content

Commit

Permalink
Add fixed pause setting. Resolves splewis#54.
Browse files Browse the repository at this point in the history
  • Loading branch information
splewis committed Oct 1, 2016
1 parent 72cbb3a commit e7570ee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ You should either set these in the above file, or in the match config's ``cvars`
- ``get5_max_pauses``: maximum number of pauses a team can use, 0=unlimited
- ``get5_max_pause_time``: maximum number of time the game can spend paused by a team, 0=unlimited
- ``get5_reset_pauses_each_half``: whether pause limits are reset each halftime period (default 1)
- ``get5_fixed_pause_time``: if nonzero, the fixed length all pauses will be
- ``get5_pausing_enabled``: whether pausing (!pause command) is enabled
- ``get5_stats_path_format``: path where stats are output each map end if set
- ``get5_stop_command_enabled``: whether the !stop command is enabled
Expand Down
12 changes: 10 additions & 2 deletions scripting/get5.sp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ConVar g_BackupSystemEnabledCvar;
ConVar g_CheckAuthsCvar;
ConVar g_DemoNameFormatCvar;
ConVar g_EventLogFormatCvar;
ConVar g_FixedPauseTimeCvar;
ConVar g_KickClientsWithNoMatchCvar;
ConVar g_LiveCfgCvar;
ConVar g_LiveCountdownTimeCvar;
Expand Down Expand Up @@ -214,6 +215,8 @@ public void OnPluginStart() {
g_EventLogFormatCvar = CreateConVar("get5_event_log_format",
"logs/get5_match{MATCHID}_event_log.log",
"Path to use when writing match event logs, use \"\" to disable");
g_FixedPauseTimeCvar = CreateConVar("get5_fixed_pause_time", "0",
"If set to non-zero, this will be the fixed length of any pause");
g_KickClientsWithNoMatchCvar = CreateConVar("get5_kick_when_no_match_loaded", "1",
"Whether the plugin kicks new clients when no match is loaded");
g_LiveCfgCvar = CreateConVar("get5_live_cfg", "get5/live.cfg",
Expand Down Expand Up @@ -589,13 +592,18 @@ public Action Command_Pause(int client, int args) {

g_TeamReadyForUnpause[MatchTeam_Team1] = false;
g_TeamReadyForUnpause[MatchTeam_Team2] = false;
Pause();

// If the pause will need explicit resuming, we will create a timer to poll the pause status.
bool need_resume = Pause(g_FixedPauseTimeCvar.IntValue, MatchTeamToCSTeam(team));
if (IsPlayer(client)) {
Get5_MessageToAll("%t", "MatchPausedByTeamMessage", client);
}

if (IsPlayerTeam(team)) {
CreateTimer(1.0, Timer_PauseTimeCheck, team, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
if (need_resume) {
CreateTimer(1.0, Timer_PauseTimeCheck, team, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}

g_TeamPausesUsed[team]++;
}

Expand Down
18 changes: 16 additions & 2 deletions scripting/get5/util.sp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,22 @@ stock bool IsPaused() {
return GameRules_GetProp("m_bMatchWaitingForResume") != 0;
}

stock void Pause() {
ServerCommand("mp_pause_match");
// Pauses and returns if the match will automatically unpause after the duration ends.
stock bool Pause(int pauseTime=0, int csTeam=CS_TEAM_NONE) {
if (pauseTime == 0 || csTeam == CS_TEAM_SPECTATOR || csTeam == CS_TEAM_NONE) {
ServerCommand("mp_pause_match");
return false;
} else {
ServerCommand("mp_pause_match");
if (csTeam == CS_TEAM_T) {
GameRules_SetProp("m_bTerroristTimeOutActive", true);
GameRules_SetPropFloat("m_flTerroristTimeOutRemaining", float(pauseTime));
} else {
GameRules_SetProp("m_bCTTimeOutActive", true);
GameRules_SetPropFloat("m_flCTTimeOutRemaining", float(pauseTime));
}
return true;
}
}

stock void Unpause() {
Expand Down

0 comments on commit e7570ee

Please sign in to comment.