Raised This Month: $ Target: $400
 0% 

spectator sp help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
smt287
Member
Join Date: Aug 2011
Location: Anywhere
Old 08-07-2017 , 21:04   spectator sp help
Reply With Quote #1

hello,
i wanted spectator count and names for this sp on hint.

Code:
public Action:Timer_UpdateHudHint(Handle:timer, any:client)
{
	new iSpecModeUser = GetEntProp(client, Prop_Send, "m_iObserverMode");
	new iSpecMode, iTarget, iTargetUser;
	
	decl String:sText[254];
	new iCount = -1;
	
	// Dealing with a client who is in the game and playing.
	if (IsPlayerAlive(client))
	{
		for(new i = 1; i <= MaxClients; i++) 
		{
			if (!IsClientInGame(i) || !IsClientObserver(i))
				continue;
				
			iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
			
			// The client isn't spectating any one person, so ignore them.
			if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
				continue;
			
			// Find out who the client is spectating.
			iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
			
			// Are they spectating our player?
			if (iTarget == client)
			{
				iCount++;
			}
		}
	}
	else if (iSpecModeUser == SPECMODE_FIRSTPERSON || iSpecModeUser == SPECMODE_3RDPERSON)
	{
		// Find out who the User is spectating.
		iTargetUser = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
		
		if (iTargetUser > -1)
			iCount++;
		
		for(new i = 1; i <= MaxClients; i++) 
		{
			if (!IsClientInGame(i) || !IsClientObserver(i))
				continue;
				
			iSpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
			
			// The client isn't spectating any one person, so ignore them.
			if (iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON)
				continue;
			
			// Find out who the client is spectating.
			iTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
			
			// Are they spectating the same player as User?
			if (iTarget == iTargetUser)
				iCount++;
		}
	}
	
	if(iCount > 0)
	{
		if(client)
		{
			Format(sText, sizeof(sText), "Name: %N  SpecCount: %i", client, iCount);
			PrintHintText(client, sText);
		}
		if(iTargetUser)
		{
			Format(sText, sizeof(sText), "Name: %N  SpecCount: %i", iTargetUser, iCount);
			PrintHintText(client, sText);
		}
	}

	return Plugin_Continue;

sorry for my bad england
__________________
smt287 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 08-10-2017 , 16:33  
Reply With Quote #2

PHP Code:
public Action SpecListLoadHUD(Handle timerany client)
{
    static 
int num;
    static 
char buffer[512];
    
buffer[0] = '\0';

    if(
IsPlayerAlive(client)) FillSpecList(clientclientbuffersizeof(buffer), num);
    else
    {
        static 
int iSpecMode;
        
iSpecMode GetEntProp(clientProp_Send"m_iObserverMode");
        if(
iSpecMode == || iSpecMode == 5)
            
FillSpecList(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"), buffersizeof(buffer), num);
    }

    if(
num)
    {
        
FormatEx(buffersizeof(buffer), "Spectators (%i):\n%s"numbuffer);
        
PrintHintText(clientbuffer);
    }

    return 
Plugin_Continue;
}

void FillSpecList(int clientint targetchar[] speclistint listmaxsizeint num)
{
    
num 0;
    static 
char sName[32];
    for(
int i 1<= MaxClientsi++)
    {
        if(
== client || == target) continue;

        if(!
IsClientInGame(i) || !IsClientObserver(i)) continue;

        if(
bIsAdmin[i] && !bAdminIsVisible && !(bIsAdmin[client] && bAdminCanSee)) continue;

        static 
int iSpecMode;
        
iSpecMode GetEntProp(iProp_Send"m_iObserverMode");
        if(
iSpecMode != && iSpecMode != 5) continue;

        if(
GetEntPropEnt(iProp_Send"m_hObserverTarget") == target)
        {
            
num++;
            if(
GetClientName(isNamesizeof(sName))) FormatEx(speclistlistmaxsize"%s\n%s"speclistsName);
        }
    }

__________________

Last edited by Grey83; 08-10-2017 at 16:35.
Grey83 is offline
smt287
Member
Join Date: Aug 2011
Location: Anywhere
Old 08-23-2017 , 11:48   Re: spectator sp help
Reply With Quote #3

Not working
ERROR: http://prntscr.com/gc4rk2
__________________
smt287 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 08-23-2017 , 13:32   Re: spectator sp help
Reply With Quote #4

just remove this line
__________________
Grey83 is offline
smt287
Member
Join Date: Aug 2011
Location: Anywhere
Old 08-23-2017 , 15:34   Re: spectator sp help
Reply With Quote #5


error img: http://prntscr.com/gc7n57
__________________
smt287 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 08-23-2017 , 22:11   Re: spectator sp help
Reply With Quote #6

better post whole code, what you want compile
__________________
Grey83 is offline
smt287
Member
Join Date: Aug 2011
Location: Anywhere
Old 08-24-2017 , 09:30   Re: spectator sp help
Reply With Quote #7

Quote:
Originally Posted by Grey83 View Post
better post whole code, what you want compile
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <multicolors>

#define SPECMODE_NONE                 0
#define SPECMODE_FIRSTPERSON         4
#define SPECMODE_3RDPERSON             5
#define SPECMODE_FREELOOK             6

#define UPDATE_INTERVAL 1.0
#define PLUGIN_VERSION "1.3"

new Handle:HudHintTimers[MAXPLAYERS+1];
new 
Handle:sm_speclist_enabled;
new 
Handle:sm_speclist_allowed;
new 
Handle:sm_speclist_adminonly;
new 
bool:g_Enabled;
new 
bool:g_AdminOnly;
 
public 
Plugin:myinfo =
{
    
name "Izleyici Listesi",
    
author "",
    
description "Sizi kimler izliyor öğrenin",
    
version PLUGIN_VERSION,
    
url ""
};
 
public 
OnPluginStart()
{
    
CreateConVar("sm_izleyicilistesi_surum"PLUGIN_VERSION"İzleyici Listesi Eklenti Sürümü"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
sm_speclist_enabled CreateConVar("sm_izleyicilistesi","1","İzleyici listesini aktif eder");
    
sm_speclist_allowed CreateConVar("sm_izleyicilistesi_izin","1","İzleyici listesi manuel olarak devre dışı bırakıldığında oyuncuların aktif etmesine izin verir");
    
sm_speclist_adminonly CreateConVar("sm_izleyicilistesi_yetkili","0","Sadece yetkililerin kullanmasına izin verir");
    
    
RegConsoleCmd("sm_speclist"Command_SpecList);
    
RegConsoleCmd("sm_izleyicilistesi"Command_SpecList);
    
RegConsoleCmd("sm_izliste"Command_SpecList);
    
    
HookConVarChange(sm_speclist_enabledOnConVarChange);
    
HookConVarChange(sm_speclist_adminonlyOnConVarChange);
    
    
g_Enabled GetConVarBool(sm_speclist_enabled);
    
g_AdminOnly GetConVarBool(sm_speclist_adminonly);
    
    
AutoExecConfig(true"so_izleyicilistesi");
}

public 
OnConVarChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
{
    if (
hCvar == sm_speclist_enabled)
    {
        
g_Enabled GetConVarBool(sm_speclist_enabled);
        
        if (
g_Enabled)
        {
            for(new 
1<= MaxClientsi++) 
            {
                if (!
IsClientInGame(i))
                    continue;
                
                
CreateHudHintTimer(i);
            }
        }
        else
        {
            for(new 
1<= MaxClientsi++) 
                
KillHudHintTimer(i);
        }
    }
    else if (
hCvar == sm_speclist_adminonly)
    {
        
g_AdminOnly GetConVarBool(sm_speclist_adminonly);
        
        if (
g_AdminOnly)
        {
            for(new 
1<= MaxClientsi++) 
                
KillHudHintTimer(i);
                
            for(new 
1<= MaxClientsi++) 
            {
                if (!
IsClientInGame(i))
                    continue;
                
                
CreateHudHintTimer(i);
            }
        }
    }
}

public 
OnClientPostAdminCheck(client)
{
    if (
g_Enabled)
        
CreateHudHintTimer(client);
}

public 
OnClientDisconnect(client)
{
    
KillHudHintTimer(client);
}

public 
Action:Command_SpecList(clientargs)
{
    if (
HudHintTimers[client] != INVALID_HANDLE)
    {
        
KillHudHintTimer(client);
        
CReplyToCommand(client"{default}[{darkred}İzleyici{default}]{green} Liste devre dışı bırakıldı!");
    }
    else if (
g_Enabled || GetConVarBool(sm_speclist_allowed))
    {
        
CreateHudHintTimer(client);
        
CReplyToCommand(client"{default}[{darkred}İzleyici{default}]{green} Liste aktif edildi!");
    }
    
    return 
Plugin_Handled;
}

public 
Action SpecListLoadHUD(Handle timerany client)
{
    static 
int num;
    static 
char buffer[512];
    
buffer[0] = '\0';

    if(
IsPlayerAlive(client)) FillSpecList(clientclientbuffersizeof(buffer), num);
    else
    {
        static 
int iSpecMode;
        
iSpecMode GetEntProp(clientProp_Send"m_iObserverMode");
        if(
iSpecMode == || iSpecMode == 5)
            
FillSpecList(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"), buffersizeof(buffer), num);
    }

    if(
num)
    {
        
FormatEx(buffersizeof(buffer), "Izleyenler (%i):\n%s"numbuffer);
        
PrintHintText(clientbuffer);
    }

    return 
Plugin_Continue;
}

void FillSpecList(int clientint targetchar[] speclistint listmaxsizeint num)
{
    
num 0;
    static 
char sName[32];
    for(
int i 1<= MaxClientsi++)
    {
        if(
== client || == target) continue;

        if(!
IsClientInGame(i) || !IsClientObserver(i)) continue;

        
//if(bIsAdmin[i] && !bAdminIsVisible && !(bIsAdmin[client] && bAdminCanSee)) continue;

        
static int iSpecMode;
        
iSpecMode GetEntProp(iProp_Send"m_iObserverMode");
        if(
iSpecMode != && iSpecMode != 5) continue;

        if(
GetEntPropEnt(iProp_Send"m_hObserverTarget") == target)
        {
            
num++;
            if(
GetClientName(isNamesizeof(sName))) FormatEx(speclistlistmaxsize"%s\n%s"speclistsName);
        }
    }


CreateHudHintTimer(client)
{
    
// If AdminOnly is enabled, make sure we only create timers on admins.
    
new AdminId:admin GetUserAdmin(client);
    
    if (!
g_AdminOnly || (g_AdminOnly && GetAdminFlag(adminAdmin_GenericAccess_Effective)))
        
HudHintTimers[client] = CreateTimer(UPDATE_INTERVALTimer_UpdateHudHintclientTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

KillHudHintTimer(client)
{
    if (
HudHintTimers[client] != INVALID_HANDLE)
    {
        
KillTimer(HudHintTimers[client]);
        
HudHintTimers[client] = INVALID_HANDLE;
    }

__________________

Last edited by smt287; 08-24-2017 at 09:30.
smt287 is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 08-24-2017 , 10:18   Re: spectator sp help
Reply With Quote #8

PHP Code:
#pragma semicolon 1
#include <multicolors>
#pragma newdecls required

static const int SPECMODE_FIRSTPERSON    4,
                
SPECMODE_3RDPERSON        5;

static const 
float UPDATE_INTERVAL    1.5;
static const 
char PLUGIN_VERSION[]    = "1.2.0";


Handle HintTimers[MAXPLAYERS+1];
bool g_bEnabled,
    
g_bAllowed,
    
g_bAdminOnly,
    
g_bNoAdmins;

public 
Plugin myinfo =
{
    
name        "Spectator List",
    
author        "GoD-Tony (rewritten by Grey83)",
    
description    "View who is spectating you in CSGO",
    
version        PLUGIN_VERSION,
    
url            "https://forums.alliedmods.net/showthread.php?t=135353"
};

public 
void OnPluginStart()
{
    
CreateConVar("sm_speclist_version"PLUGIN_VERSION"Spectator List CSGO Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
ConVar CVar;
    
HookConVarChange((CVar CreateConVar("sm_speclist_enabled","1","Enables the spectator list for all players by default."FCVAR_NONEtrue0.0true1.0)), CVarChange_Enabled);
    
g_bEnabled        CVar.BoolValue;
    
HookConVarChange((CVar CreateConVar("sm_speclist_allowed","1","Allows players to enable spectator list manually when disabled by default."FCVAR_NONEtrue0.0true1.0)), CVarChange_Allowed);
    
g_bAllowed        CVar.BoolValue;
    
HookConVarChange((CVar CreateConVar("sm_speclist_adminonly","0","Only admins can use the features of this plugin."FCVAR_NONEtrue0.0true1.0)), CVarChange_AdminOnly);
    
g_bAdminOnly    CVar.BoolValue;
    
HookConVarChange((CVar CreateConVar("sm_speclist_noadmins""1","Don't show non-admins that admins are spectating them."FCVAR_NONEtrue0.0true1.0)), CVarChange_NoAdmins);
    
g_bNoAdmins        CVar.BoolValue;

    
RegConsoleCmd("sm_speclist"Cmd_SpecList);
    
RegConsoleCmd("sm_izleyicilistesi"Cmd_SpecList);
    
RegConsoleCmd("sm_izliste"Cmd_SpecList);

    
AutoExecConfig(true"plugin.speclist_csgo");
}

public 
void CVarChange_Enabled(ConVar CVar, const char[] oldValue, const char[] newValue)
{
    
g_bEnabled CVar.BoolValue;

    if(
g_bEnabledCreateAllHintTimers();
    else 
KillAllHintTimers();
}

public 
void CVarChange_Allowed(ConVar CVar, const char[] oldValue, const char[] newValue)
{
    
g_bAllowed CVar.BoolValue;
}

public 
void CVarChange_AdminOnly(ConVar CVar, const char[] oldValue, const char[] newValue)
{
    
g_bAdminOnly CVar.BoolValue;

    if(
g_bAdminOnly)KillAllHintTimers();
    {
        
KillAllHintTimers();
        
CreateAllHintTimers();
    }
}

public 
void CVarChange_NoAdmins(ConVar CVar, const char[] oldValue, const char[] newValue)
{
    
g_bNoAdmins CVar.BoolValue;

    if(
g_bNoAdmins)
    {
        
KillAllHintTimers();
        
CreateAllHintTimers();
    }
}

void KillAllHintTimers()        // Kill all of the active timers.
{
    for(
int i 1<= MaxClientsi++) KillHintTimer(i);
}

void CreateAllHintTimers()    // Enable timers on all players in game.
{
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i)) continue;
        
CreateHintTimer(i);
    }
}

public 
void OnClientPostAdminCheck(int client)
{
    if(
g_bEnabledCreateHintTimer(client);
}

public 
void OnClientDisconnect(int client)
{
    if(
IsClientInGame(client)) KillHintTimer(client);
}

// Using 'sm_speclist' to toggle the spectator list per player.
public Action Cmd_SpecList(int clientint args)
{
    if(
HintTimers[client] != null)
    {
        
KillHintTimer(client);
        
CReplyToCommand(client"{default}[{darkred}İzleyici{default}]{green} Liste devre dışı bırakıldı!");
    }
    else if(
g_bEnabled || g_bAllowed)
    {
        
CreateHintTimer(client);
        
CReplyToCommand(client"{default}[{darkred}İzleyici{default}]{green} Liste aktif edildi!");
    }

    return 
Plugin_Handled;
}

public 
Action Timer_UpdateHint(Handle timerany client)
{
    static 
int num;
    static 
char buffer[512];
    
buffer[0] = '\0';

    if(
IsPlayerAlive(client)) FillSpecList(clientclientbuffersizeof(buffer), num);
    else
    {
        static 
int iSpecMode;
        
iSpecMode GetEntProp(clientProp_Send"m_iObserverMode");
        if(
iSpecMode == || iSpecMode == 5)
            
FillSpecList(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"), buffersizeof(buffer), num);
    }

    if(
num)
    {
        
FormatEx(buffersizeof(buffer), "Izleyenler (%i):\n%s"numbuffer);
        
PrintHintText(clientbuffer);
    }

    return 
Plugin_Continue;
}

void FillSpecList(int clientint targetchar[] speclistint listmaxsizeint num)
{
    
num 0;
    static 
char sName[32];
    for(
int i 1<= MaxClientsi++)
    {
        if(
== client || == target) continue;

        if(!
IsClientInGame(i) || !IsClientObserver(i)) continue;

        static 
int iSpecMode;
        
iSpecMode GetEntProp(iProp_Send"m_iObserverMode");
        if(
iSpecMode != SPECMODE_FIRSTPERSON && iSpecMode != SPECMODE_3RDPERSON) continue;

        if(
GetEntPropEnt(iProp_Send"m_hObserverTarget") == target)
        {
            
num++;
            if(
GetClientName(isNamesizeof(sName))) FormatEx(speclistlistmaxsize"%s\n%s"speclistsName);
        }
    }
}

void CreateHintTimer(int client)
{
    
// If AdminOnly is enabled, make sure we only create timers on admins.
    
if(!g_bAdminOnly || (g_bAdminOnly && IsPlayerAdmin(client))) HintTimers[client] = CreateTimer(UPDATE_INTERVALTimer_UpdateHintclientTIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

void KillHintTimer(int client)
{
    if(
HintTimers[client] != null)
    {
        
KillTimer(HintTimers[client]);
        
HintTimers[client] = null;
    }
}

bool IsPlayerAdmin(int client)
{
    return (
IsClientInGame(client) && GetUserAdmin(client) != INVALID_ADMIN_ID);

__________________

Last edited by Grey83; 08-24-2017 at 10:21.
Grey83 is offline
smt287
Member
Join Date: Aug 2011
Location: Anywhere
Old 08-24-2017 , 11:15   Re: spectator sp help
Reply With Quote #9

No error but it does not work
__________________
smt287 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode