From 09ce29cda80c934593cef8cb9f9678cc94b589fe Mon Sep 17 00:00:00 2001 From: BotoX Date: Sat, 26 Oct 2019 01:27:51 +0200 Subject: [PATCH] RadarSpotAll: add sm_radar_mode --- RadarSpotAll/scripting/RadarSpotAll.sp | 77 +++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/RadarSpotAll/scripting/RadarSpotAll.sp b/RadarSpotAll/scripting/RadarSpotAll.sp index f3ed6142..bc07d683 100644 --- a/RadarSpotAll/scripting/RadarSpotAll.sp +++ b/RadarSpotAll/scripting/RadarSpotAll.sp @@ -1,6 +1,7 @@ #include #include #include +#include #pragma semicolon 1 #pragma newdecls required @@ -14,14 +15,56 @@ public Plugin myinfo = url = "" }; +ConVar g_cRadarMode; +int g_RadarMode; + int g_hPlayerSpotted; -int g_aSpottedPlayers[MAXPLAYERS+1] = {1, ...}; +int g_aSpottedPlayers[MAXPLAYERS+1]; public void OnPluginStart() { g_hPlayerSpotted = FindSendPropInfo("CCSPlayerResource", "m_bPlayerSpotted"); if(g_hPlayerSpotted == -1) SetFailState("Couldn't find CCSPlayerResource::m_bPlayerSpotted"); + + g_cRadarMode = CreateConVar("sm_radar_mode", "2", "RadarSpotAll mode: 0 = Default, 1 = Show zombies, 2 = Show all, 3 = Show none", FCVAR_NONE, true, 0.0, true, 3.0); + g_cRadarMode.AddChangeHook(RadarModeChanged); + + HookEvent("player_spawn", Event_Spawn, EventHookMode_Post); + + AutoExecConfig(true); +} + +public void RadarModeChanged(ConVar cvar, const char[] sOldVal, const char[] sNewVal) +{ + g_RadarMode = cvar.IntValue; + + for(int client = 1; client < MaxClients; client++) + { + if(g_RadarMode == 0) + { + g_aSpottedPlayers[client] = 0; + } + else if(g_RadarMode == 1) + { + if(IsClientInGame(client) && IsPlayerAlive(client) && ZR_IsClientZombie(client)) + { + g_aSpottedPlayers[client] = 1; + } + else + { + g_aSpottedPlayers[client] = 0; + } + } + else if(g_RadarMode == 2) + { + g_aSpottedPlayers[client] = 1; + } + else if(g_RadarMode == 3) + { + g_aSpottedPlayers[client] = 0; + } + } } public void OnMapStart() @@ -35,5 +78,37 @@ public void OnMapStart() public void OnThinkPost(int entity) { + if(!g_RadarMode) + return; + SetEntDataArray(entity, g_hPlayerSpotted, g_aSpottedPlayers, MAXPLAYERS+1, 1, true); } + + +public void Event_Spawn(Event event, const char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(GetEventInt(event, "userid")); + if(!client) + return; + + if(g_RadarMode == 1) + { + g_aSpottedPlayers[client] = 0; + } +} + +public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn) +{ + if(g_RadarMode == 1) + { + g_aSpottedPlayers[client] = 1; + } +} + +public void ZR_OnClientHumanPost(int client, bool respawn, bool protect) +{ + if(g_RadarMode == 1) + { + g_aSpottedPlayers[client] = 0; + } +}