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

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;
}

View File

@ -48,7 +48,7 @@ stock LogPlayerEvent(client, const String:verb[], const String:event[], bool:dis
if (IsValidPlayer(client))
{
decl String:player_authid[32];
if (!GetClientAuthString(client, player_authid, sizeof(player_authid)))
if (!GetClientAuthId(client, AuthId_Steam2, player_authid, sizeof(player_authid)))
{
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
}
@ -74,12 +74,12 @@ stock LogPlyrPlyrEvent(client, victim, const String:verb[], const String:event[]
if (IsValidPlayer(client) && IsValidPlayer(victim))
{
decl String:player_authid[32];
if (!GetClientAuthString(client, player_authid, sizeof(player_authid)))
if (!GetClientAuthId(client, AuthId_Steam2, player_authid, sizeof(player_authid)))
{
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid)))
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}
@ -106,12 +106,12 @@ stock LogKill(attacker, victim, const String:weapon[], bool:display_location = f
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
{
decl String:attacker_authid[32];
if (!GetClientAuthString(attacker, attacker_authid, sizeof(attacker_authid)))
if (!GetClientAuthId(attacker, AuthId_Steam2, attacker_authid, sizeof(attacker_authid)))
{
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid)))
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}
@ -138,12 +138,12 @@ stock LogPSKillTraj(attacker, victim, const String:weapon[])
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
{
decl String:attacker_authid[32];
if (!GetClientAuthString(attacker, attacker_authid, sizeof(attacker_authid)))
if (!GetClientAuthId(attacker, AuthId_Steam2, attacker_authid, sizeof(attacker_authid)))
{
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthString(victim, victim_authid, sizeof(victim_authid)))
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}