2019-10-20 23:01:59 +02:00
# include <sourcemod>
# include <sdkhooks>
2019-10-21 00:16:02 +02:00
# include <sdktools>
2019-10-26 01:27:51 +02:00
# include <zombiereloaded>
2019-10-20 23:01:59 +02:00
# pragma semicolon 1
# pragma newdecls required
public Plugin myinfo =
{
name = " RadarSpotAll " ,
author = " BotoX " ,
description = " Always spot every player on the radar. " ,
version = " 1.0 " ,
url = " "
} ;
2019-10-26 01:27:51 +02:00
ConVar g_cRadarMode ;
int g_RadarMode ;
2019-10-21 00:16:02 +02:00
int g_hPlayerSpotted ;
2019-10-26 01:27:51 +02:00
int g_aSpottedPlayers [ MAXPLAYERS + 1 ] ;
2019-10-21 00:16:02 +02:00
public void OnPluginStart ( )
2019-10-20 23:01:59 +02:00
{
2019-10-21 00:16:02 +02:00
g_hPlayerSpotted = FindSendPropInfo ( " CCSPlayerResource " , " m_bPlayerSpotted " ) ;
if ( g_hPlayerSpotted = = - 1 )
SetFailState ( " Couldn't find CCSPlayerResource::m_bPlayerSpotted " ) ;
2019-10-26 01:27:51 +02:00
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 ) ;
2019-10-30 23:16:39 +01:00
RadarModeChanged ( g_cRadarMode , " " , " " ) ;
2019-10-26 01:27:51 +02:00
}
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 ;
}
}
2019-10-21 00:16:02 +02:00
}
public void OnMapStart ( )
{
int entity = FindEntityByClassname ( MaxClients + 1 , " cs_player_manager " ) ;
if ( entity = = - 1 )
SetFailState ( " Unable to find cs_player_manager entity " ) ;
SDKHook ( entity , SDKHook_ThinkPost , OnThinkPost ) ;
2019-10-20 23:01:59 +02:00
}
2019-10-21 00:16:02 +02:00
public void OnThinkPost ( int entity )
2019-10-20 23:01:59 +02:00
{
2019-10-26 01:27:51 +02:00
if ( ! g_RadarMode )
return ;
2019-11-03 21:38:11 +01:00
if ( g_RadarMode = = 1 )
{
for ( int client = 1 ; client < MaxClients ; client + + )
{
if ( g_aSpottedPlayers [ client ] )
SetEntData ( entity , g_hPlayerSpotted + client , 1 , 1 , true ) ;
}
}
else
{
SetEntDataArray ( entity , g_hPlayerSpotted , g_aSpottedPlayers , MAXPLAYERS + 1 , 1 , true ) ;
}
2019-10-20 23:01:59 +02:00
}
2019-10-26 01:27:51 +02:00
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 ;
}
}