Raised This Month: $51 Target: $400
 12% 

[Any] Allow Admins to spectate the other team


Post New Thread Reply   
 
Thread Tools Display Modes
Dreamy
SourceMod Donor
Join Date: Mar 2012
Old 03-14-2012 , 12:19   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #11

nah there was a reason why I created a timer..

but its actually quite simple with sdkhooks:
PHP Code:
#include <sourcemod>
#include <sdkhooks>

public OnPluginStart()
    
HookEvent("player_death"Event_Death);

public 
Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
GetUserAdmin(client) == INVALID_ADMIN_ID)
        
SDKHook(clientSDKHook_PostThinkCheckObserver);
}

public 
Action:CheckObserver(client)
{
    new 
team GetClientTeam(client);
    new 
ent GetEntPropEnt(clientProp_Send"m_hObserverTarget");
    if (
team != GetClientTeam(ent))
    {
        for (new 
1MaxClients+1i++)
        {
            if (
IsClientInGame(i))
            {
                if (
IsPlayerAlive(i) && (team == GetClientTeam(i)))
                {
                    
SetEntPropEnt(clientProp_Send"m_hObserverTarget"i);
                    return 
Plugin_Handled;
                }
            }
        }
    }
    return 
Plugin_Handled;


Last edited by Dreamy; 03-14-2012 at 12:31.
Dreamy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-14-2012 , 12:46   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #12

sorry, you're right - doesn't really matter I guess
__________________
View my Plugins | Donate

Last edited by TnTSCS; 03-14-2012 at 22:06.
TnTSCS is offline
FudgePoly
Senior Member
Join Date: Jul 2011
Old 03-14-2012 , 12:47   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #13

Quote:
Originally Posted by Dreamy View Post
nah there was a reason why I created a timer..

but its actually quite simple with sdkhooks:
PHP Code:
#include <sourcemod>
#include <sdkhooks>

public OnPluginStart()
    
HookEvent("player_death"Event_Death);

public 
Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
GetUserAdmin(client) == INVALID_ADMIN_ID)
        
SDKHook(clientSDKHook_PostThinkCheckObserver);
}

public 
Action:CheckObserver(client)
{
    new 
team GetClientTeam(client);
    new 
ent GetEntPropEnt(clientProp_Send"m_hObserverTarget");
    if (
team != GetClientTeam(ent))
    {
        for (new 
1MaxClients+1i++)
        {
            if (
IsClientInGame(i))
            {
                if (
IsPlayerAlive(i) && (team == GetClientTeam(i)))
                {
                    
SetEntPropEnt(clientProp_Send"m_hObserverTarget"i);
                    return 
Plugin_Handled;
                }
            }
        }
    }
    return 
Plugin_Handled;

Code:
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
L 03/14/2012 - 18:42:43: [SM] Native "GetClientTeam" reported: Client index 151 is invalid
L 03/14/2012 - 18:42:43: [SM] Displaying call stack trace for plugin "admincam.smx":
L 03/14/2012 - 18:42:43: [SM]   [0]  Line 18, admincam.sp::CheckObserver()
Oh boy...
FudgePoly is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-14-2012 , 12:49   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #14

again, sorry about pointing stuff out
__________________
View my Plugins | Donate

Last edited by TnTSCS; 03-14-2012 at 22:06.
TnTSCS is offline
Dreamy
SourceMod Donor
Join Date: Mar 2012
Old 03-14-2012 , 13:05   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #15

**lets remove our posts so others dont see our buggy code anymore
and while we are at it, lets make it appear like somebody explicitly told us to remove them**

Last edited by Dreamy; 03-15-2012 at 00:10.
Dreamy is offline
FudgePoly
Senior Member
Join Date: Jul 2011
Old 03-14-2012 , 13:26   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #16

I have root access and I still can't spectate the other team 100% of the time, it's almost random... (using the fixed version). Does this work in TF2 arena or is that the issue?
FudgePoly is offline
Dreamy
SourceMod Donor
Join Date: Mar 2012
Old 03-14-2012 , 13:42   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #17

**removing posts is so fun**

Last edited by Dreamy; 03-15-2012 at 00:11.
Dreamy is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-14-2012 , 14:41   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #18

*post removed.

Ask me if you want to see the code I had - don't want people thinking I'm jumping their work!!
__________________
View my Plugins | Donate

Last edited by TnTSCS; 03-14-2012 at 22:06.
TnTSCS is offline
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 03-14-2012 , 19:29   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #19

*post removed.

Ask me if you want to see the code I had - don't want people thinking I'm jumping their work!!
__________________
View my Plugins | Donate

Last edited by TnTSCS; 03-14-2012 at 22:06.
TnTSCS is offline
Dreamy
SourceMod Donor
Join Date: Mar 2012
Old 03-14-2012 , 19:54   Re: [Any] Allow Admins to spectate the other team
Reply With Quote #20

set mp_forcecamera 0 and try this:
PHP Code:
#pragma semicolon 1
#include <sourcemod>

#define FFADE_IN               0x0001
#define FFADE_OUT           0x0002  
#define FFADE_STAYOUT       0x0008
#define FFADE_PURGE         0x0010

public OnPluginStart()
{
    
HookEvent("player_death"Event_Death); 
}

public 
Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
GetUserAdmin(client) != INVALID_ADMIN_ID)
        return 
Plugin_Continue;
    
    
PerformFade(client);
    
CreateTimer(7.0SpecTeamclient);
    return 
Plugin_Continue;
}

public 
Action:OnClientCommand(clientargs)
{
    if (
GetUserAdmin(client) != INVALID_ADMIN_ID)
        return 
Plugin_Continue;
    
    
decl String:arg[128];
    
GetCmdArg(0argsizeof(arg));

    if (
StrEqual(arg"spec_mode"))
        return 
Plugin_Handled;
    
    if (
StrEqual(arg"spec_next"))
    {
        
SpecNext(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"));
        return 
Plugin_Handled;
    }
    else if(
StrEqual(arg"spec_prev"))
    {
        
SpecPrev(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"));
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;
}

stock SpecNext(clientcurrent)
{
    new 
team GetClientTeam(client);
    for (new 
current+1!= currenti++)
    {    
        if (
team == GetClientTeamEx(i))
        {
            
SetEntPropEnt(clientProp_Send"m_hObserverTarget"i);
            return;
        }
        if (
== MaxClients)
            
1;
    }
}

stock SpecPrev(clientcurrent)
{
    new 
team GetClientTeam(client);
    for (new 
current-1!= currenti--)
    {
        if (
team == GetClientTeamEx(i))
        {
            
SetEntPropEnt(clientProp_Send"m_hObserverTarget"i);
            return;
        }
        if (
== 1)
            
MaxClients;
    }
}

GetClientTeamEx(client)
{
    return (!
client || !IsClientInGame(client) || !IsPlayerAlive(client)) ? -1:GetClientTeam(client);
}

public 
Action:SpecTeam(Handle:timerany:client)
{
    
SetEntProp(clientProp_Send"m_iObserverMode"4);
    
SpecNext(clientGetEntPropEnt(clientProp_Send"m_hObserverTarget"));
    return 
Plugin_Handled;
}

public 
PerformFade(client)
{
    new 
Handle:hFadeClient StartMessageOne("Fade"client);
    
BfWriteShort(hFadeClient3250);
    
BfWriteShort(hFadeClient350);
    
BfWriteShort(hFadeClient, (FFADE_OUT|FFADE_PURGE));
    
BfWriteByte(hFadeClient0);
    
BfWriteByte(hFadeClient0);
    
BfWriteByte(hFadeClient0);
    
BfWriteByte(hFadeClient255);
    
EndMessage();

this is just to see if its working or not (so dont complain about OnClientCommand), I can make a plugin out of it if everything is alright.

Last edited by Dreamy; 03-14-2012 at 22:37.
Dreamy 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 09:17.


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