Spectate: don't require zombiereloaded

This commit is contained in:
BotoX
2019-12-05 19:44:21 +01:00
parent ca37ab2a84
commit 85a94837a2
2 changed files with 42 additions and 13 deletions
+35 -6
View File
@@ -3,11 +3,15 @@
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <zombiereloaded>
#undef REQUIRE_PLUGIN
#tryinclude <zombiereloaded>
#define REQUIRE_PLUGIN
#include "loghelper.inc"
#pragma newdecls required
bool g_bZRLoaded;
Handle g_hFwd_SpectateByCommand;
bool g_bRoundEnd;
@@ -53,6 +57,23 @@ public void OnPluginStart()
HookEvent("round_end", OnRoundEnd, EventHookMode_Pre);
}
public void OnAllPluginsLoaded()
{
g_bZRLoaded = LibraryExists("zombiereloaded");
}
public void OnLibraryAdded(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = true;
}
public void OnLibraryRemoved(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = false;
}
public void OnMapStart()
{
GetTeams();
@@ -92,7 +113,8 @@ public Action Command_Spectate(int client, int argc)
return Plugin_Handled;
}
if (IsPlayerAlive(client) && ZR_IsClientZombie(client))
#if defined _zr_included
if (g_bZRLoaded && IsPlayerAlive(client) && ZR_IsClientZombie(client))
{
bool bOnlyZombie = true;
for (int i = 1; i <= MaxClients; i++)
@@ -110,13 +132,16 @@ public Action Command_Spectate(int client, int argc)
return Plugin_Handled;
}
}
#endif
if (!argc)
{
if (GetClientTeam(client) != CS_TEAM_SPECTATOR)
{
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd)
#if defined _zr_included
if (g_bZRLoaded && IsPlayerAlive(client) && ZR_IsClientHuman(client) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd)
LogPlayerEvent(client, "triggered", "switch_to_spec");
#endif
Call_StartForward(g_hFwd_SpectateByCommand);
Call_PushCell(client);
@@ -145,8 +170,10 @@ 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 && !g_bRoundEnd)
#if defined _zr_included
if (g_bZRLoaded && IsPlayerAlive(client) && ZR_IsClientHuman(client) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd)
LogPlayerEvent(client, "triggered", "switch_to_spec");
#endif
Call_StartForward(g_hFwd_SpectateByCommand);
Call_PushCell(client);
@@ -175,8 +202,10 @@ 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 && !g_bRoundEnd)
#if defined _zr_included
if (g_bZRLoaded && IsPlayerAlive(client) && ZR_IsClientHuman(client) && GetTeamAliveClientCount(CS_TEAM_T) > 0 && !g_bRoundEnd)
LogPlayerEvent(client, "triggered", "switch_to_spec");
#endif
return Plugin_Continue;
}
@@ -233,4 +262,4 @@ stock void StripPlayerKnifes(int client)
AcceptEntityInput(w, "Kill");
}
}
}
}