Ah cheers for that. I just wanted it to go before freeze time ended I think and used Event Round_Start. New pause command fixed this anyway.
PHP Code:
/* Pause and Unpause */
new bool:g_pause_freezetime = false;
new bool:g_pause_offered_t = false;
new bool:g_pause_offered_ct = false;
new bool:g_paused = false;
new Handle:sv_pausable;
new Handle:g_h_auto_unpause = INVALID_HANDLE;
new Handle:g_h_auto_unpause_delay = INVALID_HANDLE;
//new Handle:g_h_pause_freezetime = INVALID_HANDLE;
new Handle:g_h_pause_comfirm = INVALID_HANDLE;
new Handle:g_h_pause_limit = INVALID_HANDLE;
new g_t_pause_count = 0;
new g_ct_pause_count = 0;
new Handle:g_h_stored_timer = INVALID_HANDLE;
public OnPluginStart()
{
// Pause and Unpause stuff
sv_pausable = FindConVar ("sv_pausable");
g_h_pause_comfirm = CreateConVar("wm_pause_comfirm", "1", "Wait for other team to comfirm pause: 0 = off, 1 = on", FCVAR_NOTIFY);
g_h_auto_unpause = CreateConVar("wm_auto_unpause", "1", "Sets auto unpause: 0 = off, 1 = on", FCVAR_NOTIFY);
// g_h_pause_freezetime = CreateConVar("wm_pause_freezetime", "1", "Wait for freeze time to pause: 0 = off, 1 = on", FCVAR_NOTIFY);
g_h_auto_unpause_delay = CreateConVar("wm_auto_unpause_delay", "180", "Sets the seconds to wait before auto unpause", FCVAR_NOTIFY, true, 0.0);
g_h_pause_limit = CreateConVar("wm_pause_limit", "1", "Sets max pause count per team per half", FCVAR_NOTIFY);
}
public Action:SayChat(client, args)
{
if (!IsActive(0, true) || args < 1)
{
// warmod is disabled or no arguments
return Plugin_Continue;
}
new String:type[64];
GetCmdArg(0, type, sizeof(type));
new bool:teamOnly = false;
new bool:silence = false;
if (StrEqual(type, "say_team", false))
{
// true if not console, as console is always global
teamOnly = !! client;
}
new String:message[192];
GetCmdArgString(message, sizeof(message));
StripQuotes(message);
if (message[0] == '!' || message[0] == '.' || message[0] == '/')
{
if (StrEqual(command, "pause", false) || StrEqual(command, "pauses", false) || StrEqual(command, "p", false))
{
Pause(client, args);
}
else if (StrEqual(command, "unpause", false) || StrEqual(command, "unpauses", false) || StrEqual(command, "up", false))
{
Unpause(client, args);
}
}
}
public Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!IsActive(0, true))
{
return;
}
//Pause command fire on round end May change to on round start
if (g_pause_freezetime == true)
{
g_pause_freezetime = false;
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Notice", LANG_SERVER);
if(GetConVarBool(g_h_auto_unpause))
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %i %T", CHAT_PREFIX, GetConVarInt(g_h_auto_unpause_delay), "Unpause Timer", LANG_SERVER);
g_h_stored_timer = CreateTimer(GetConVarFloat(g_h_auto_unpause_delay), UnPauseTimer);
}
g_paused = true;
//ServerCommand("mp_pause_match 1");
}
}
//Pause and Unpause Commands + timers
public Action:Pause(client, args)
{
if (GetConVarBool(sv_pausable) && g_live)
{
if (GetConVarBool(g_h_pause_comfirm))
{
if (GetClientTeam(client) == 2 && g_pause_offered_ct == true)
{
if(g_h_stored_timer != INVALID_HANDLE)
{
KillTimer(g_h_stored_timer);
g_h_stored_timer = INVALID_HANDLE;
}
g_pause_offered_ct = false;
g_ct_pause_count++;
//if (GetConVarBool(g_h_pause_freezetime))
//{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Freeze Time", LANG_SERVER);
g_pause_freezetime = true;
/*}
else
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Notice", LANG_SERVER);
if (GetConVarBool(g_h_auto_unpause))
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %i %T", CHAT_PREFIX, GetConVarInt(g_h_auto_unpause_delay), "Unpause Timer", LANG_SERVER);
g_h_stored_timer = CreateTimer(GetConVarFloat(g_h_auto_unpause_delay), UnPauseTimer);
}*/
g_paused = true;
ServerCommand("mp_pause_match 1");
return;
//}
}
else if (GetClientTeam(client) == 3 && g_pause_offered_t == true)
{
if(g_h_stored_timer != INVALID_HANDLE)
{
KillTimer(g_h_stored_timer);
g_h_stored_timer = INVALID_HANDLE;
}
g_pause_offered_t = false;
g_t_pause_count++;
//if (GetConVarBool(g_h_pause_freezetime))
//{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Round End", LANG_SERVER);
g_pause_freezetime = true;
/*}
else
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Notice", LANG_SERVER);
if (GetConVarBool(g_h_auto_unpause))
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %i %T", CHAT_PREFIX, GetConVarInt(g_h_auto_unpause_delay), "Unpause Timer", LANG_SERVER);
g_h_stored_timer = CreateTimer(GetConVarFloat(g_h_auto_unpause_delay), UnPauseTimer);
}*/
g_paused = true;
ServerCommand("mp_pause_match 1");
return;
//}
}
else if (GetClientTeam(client) == 2 && g_t_pause_count == GetConVarInt(g_h_pause_limit))
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Limit", LANG_SERVER);
}
else if (GetClientTeam(client) == 3 && g_ct_pause_count == GetConVarInt(g_h_pause_limit))
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Limit", LANG_SERVER);
}
else if (GetClientTeam(client) < 2 )
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Non-player", LANG_SERVER);
}
else if (GetClientTeam(client) == 3 && g_ct_pause_count != GetConVarInt(g_h_pause_limit) && g_pause_offered_ct == false)
{
g_pause_offered_ct = true;
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_ct_name, "Pause Offer", LANG_SERVER);
g_h_stored_timer = CreateTimer(30.0, PauseTimeout);
}
else if (GetClientTeam(client) == 2 && g_t_pause_count != GetConVarInt(g_h_pause_limit) && g_pause_offered_t == false)
{
g_pause_offered_t = true;
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_t_name, "Pause Offer", LANG_SERVER);
g_h_stored_timer = CreateTimer(30.0, PauseTimeout);
}
}
else if (GetClientTeam(client) == 3 && g_ct_pause_count != GetConVarInt(g_h_pause_limit) && !GetConVarBool(g_h_pause_comfirm))
{
g_ct_pause_count++;
//if (GetConVarBool(g_h_pause_freezetime))
//{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Freeze Time", LANG_SERVER);
g_pause_freezetime = true;
/*}
else
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Notice", LANG_SERVER);
if(GetConVarBool(g_h_auto_unpause))
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %i %T", CHAT_PREFIX, GetConVarInt(g_h_auto_unpause_delay), "Unpause Timer", LANG_SERVER);
g_h_stored_timer = CreateTimer(GetConVarFloat(g_h_auto_unpause_delay), UnPauseTimer);
}*/
g_paused = true;
ServerCommand("mp_pause_match 1");
return;
//}
}
else if (GetClientTeam(client) == 2 && g_t_pause_count != GetConVarInt(g_h_pause_limit) && GetConVarBool(g_h_pause_comfirm) == false)
{
g_t_pause_count++;
//if (GetConVarBool(g_h_pause_freezetime))
//{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Freeze Time", LANG_SERVER);
g_pause_freezetime = true;
/*}
else
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Notice", LANG_SERVER);
if(GetConVarBool(g_h_auto_unpause))
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %i %T", CHAT_PREFIX, GetConVarInt(g_h_auto_unpause_delay), "Unpause Timer", LANG_SERVER);
g_h_stored_timer = CreateTimer(GetConVarFloat(g_h_auto_unpause_delay), UnPauseTimer);
}*/
g_paused = true;
ServerCommand("mp_pause_match 1");
return;
//}
}
else if (GetClientTeam(client) == 2 && g_t_pause_count == GetConVarInt(g_h_pause_limit))
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Limit", LANG_SERVER);
}
else if (GetClientTeam(client) == 3 && g_ct_pause_count == GetConVarInt(g_h_pause_limit))
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Limit", LANG_SERVER);
}
else if (GetClientTeam(client) < 2)
{
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Non-player", LANG_SERVER);
}
}
else if (!g_live)
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Match Not In Progress", LANG_SERVER);
}
else
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Not Enabled", LANG_SERVER);
}
}
public Action:Unpause(client, args)
{
if (g_paused)
{
if (GetConVarBool(g_h_pause_comfirm))
{
if (GetClientTeam(client) == 3 && g_pause_offered_ct == false && g_pause_offered_t == false)
{
g_pause_offered_ct = true;
PrintToConsoleAll("<WarMod_BFG> CT have asked to unpause the game. Please type /unpause to unpause the match.");
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_ct_name, "Unpause Offer", LANG_SERVER);
}
else if (GetClientTeam(client) == 2 && g_pause_offered_t == false && g_pause_offered_ct == false)
{
g_pause_offered_t = true;
PrintToConsoleAll("<WarMod_BFG> T have asked to unpause the game. Please type /unpause to unpause the match.");
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_t_name, "Unpause Offer", LANG_SERVER);
}
else if (GetClientTeam(client) == 2 && g_pause_offered_ct == true)
{
g_pause_offered_ct = false;
g_paused = false;
ServerCommand("mp_unpause_match 1");
}
else if (GetClientTeam(client) == 3 && g_pause_offered_t == true)
{
g_pause_offered_t = false;
g_paused = false;
ServerCommand("mp_unpause_match 1");
}
else if (GetClientTeam(client) < 2 )
{
PrintToConsole(client, "<WarMod_BFG> You must be on T or CT to enable /unpause");
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Non-player", LANG_SERVER);
}
}
else
{
if (GetClientTeam(client) == 2)
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_t_name, "Unpaused Match", LANG_SERVER);
g_paused = false;
ServerCommand("mp_unpause_match 1");
}
else if (GetClientTeam(client) == 3)
{
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %s %T", CHAT_PREFIX, g_ct_name, "Unpaused Match", LANG_SERVER);
g_paused = false;
ServerCommand("mp_unpause_match 1");
}
else if (GetClientTeam(client) < 2 )
{
PrintToConsole(client, "<WarMod_BFG> You must be on T or CT to enable /unpause");
PrintToChat(client, "\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Non-player", LANG_SERVER);
}
}
}
else
{
PrintToChat(client,"\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Paused Via Rcon", LANG_SERVER);
PrintToConsole(client,"<WarMod_BFG> Server is not paused or was paused via rcon");
}
}
public Action:PauseTimeout(Handle:timer)
{
g_h_stored_timer = INVALID_HANDLE;
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Pause Offer Not Confirmed", LANG_SERVER);
g_pause_offered_ct = false;
g_pause_offered_t = false;
}
public Action:UnPauseTimer(Handle:timer)
{
g_h_stored_timer = INVALID_HANDLE;
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %T", CHAT_PREFIX, "Unpause Auto", LANG_SERVER);
ServerCommand("mp_unpause_match 1");
g_pause_offered_ct = false;
g_pause_offered_t = false;
}