diff --git a/Spectate/scripting/Spectate.sp b/Spectate/scripting/Spectate.sp index 17b49a9a..8fcfb14b 100644 --- a/Spectate/scripting/Spectate.sp +++ b/Spectate/scripting/Spectate.sp @@ -3,11 +3,15 @@ #include #include #include -#include + +#undef REQUIRE_PLUGIN +#tryinclude +#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"); } } -} \ No newline at end of file +} diff --git a/hlstatsx/scripting/include/loghelper.inc b/hlstatsx/scripting/include/loghelper.inc index aafe0c5d..7b9a8118 100644 --- a/hlstatsx/scripting/include/loghelper.inc +++ b/hlstatsx/scripting/include/loghelper.inc @@ -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"); }