View Single Post
fraise
Member
Join Date: Sep 2016
Location: Paris, France
Old 09-29-2017 , 07:28   Re: [CSGO] How to prevent someone to spectate?!
Reply With Quote #2

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
bool spectate[MAXPLAYERS+1];
public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_stopspectate"stopspectate);
    
CreateTimer(2.0refreshspec_TIMER_REPEAT);
}

public 
Action stopspectate(int clientint 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=1i<MaxClientsi++)
    {
        if(
IsClientObserver(i))
        {
            
int ent GetEntPropEnt(iProp_Send"m_hObserverTarget");
            if(!
spectate[ent])
            {
                
PrintToChat(i"You're not allowed to watch this player");
                
SetEntProp(iProp_Send"m_iObserverMode"3);
            }
        }
    }

__________________
\o/
fraise is offline