PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
bool spectate[MAXPLAYERS+1];
public void OnPluginStart()
{
RegConsoleCmd("sm_stopspectate", stopspectate);
CreateTimer(2.0, refreshspec, _, TIMER_REPEAT);
}
public Action stopspectate(int client, int args)
{
if(spectate[client])
{
spectate[client]=false;
PrintToChat(client, "Spectate off !");
}
else if(!spectate[client])
{
spectate[client]=true;
PrintToChat(client, "Spectate on !");
}
}
public Action refreshspec(Handle timer)
{
for(int i=1; i<MaxClients; i++)
{
if(IsClientObserver(i))
{
int ent = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
if(!spectate[ent])
{
PrintToChat(i, "You're not allowed to watch this player");
SetEntProp(i, Prop_Send, "m_iObserverMode", 3);
}
}
}
}
__________________