RadarSpotAll: add sm_radar_mode

This commit is contained in:
BotoX 2019-10-26 01:27:51 +02:00
parent f2941ba952
commit 09ce29cda8

View File

@ -1,6 +1,7 @@
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <zombiereloaded>
#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;
}
}