diff --git a/Spectate/scripting/Spectate.sp b/Spectate/scripting/Spectate.sp index 0ef13238..17b49a9a 100644 --- a/Spectate/scripting/Spectate.sp +++ b/Spectate/scripting/Spectate.sp @@ -10,6 +10,8 @@ Handle g_hFwd_SpectateByCommand; +bool g_bRoundEnd; + public Plugin myinfo = { name = "Spectate", @@ -46,6 +48,9 @@ public void OnPluginStart() AddCommandListener(Command_Goto, "spec_goto"); g_hFwd_SpectateByCommand = CreateGlobalForward("OnPlayerSwitchedToSpectateByCommand", ET_Ignore, Param_Cell); + + HookEvent("round_start", OnRoundStart, EventHookMode_Post); + HookEvent("round_end", OnRoundEnd, EventHookMode_Pre); } public void OnMapStart() @@ -53,6 +58,16 @@ public void OnMapStart() GetTeams(); } +public void OnRoundStart(Event hEvent, const char[] sName, bool bDontBroadcast) +{ + g_bRoundEnd = false; +} + +public void OnRoundEnd(Event hEvent, const char[] sName, bool bDontBroadcast) +{ + g_bRoundEnd = true; +} + public void OnClientSettingsChanged(int client) { static char sSpecMode[8]; @@ -100,7 +115,7 @@ public Action Command_Spectate(int client, int argc) { if (GetClientTeam(client) != CS_TEAM_SPECTATOR) { - if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0) + if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd) LogPlayerEvent(client, "triggered", "switch_to_spec"); Call_StartForward(g_hFwd_SpectateByCommand); @@ -130,7 +145,7 @@ public Action Command_Spectate(int client, int argc) if (GetClientTeam(client) != CS_TEAM_SPECTATOR) { - if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0) + if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd) LogPlayerEvent(client, "triggered", "switch_to_spec"); Call_StartForward(g_hFwd_SpectateByCommand); @@ -160,7 +175,7 @@ public Action Command_Spectate(int client, int argc) public Action Command_Suicide(int client, char[] command, int args) { - if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0) + if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd) LogPlayerEvent(client, "triggered", "switch_to_spec"); return Plugin_Continue;