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

[Request] Making These Two Plugin Compatible


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snake.
Senior Member
Join Date: Jul 2017
Old 06-03-2022 , 07:21   [Request] Making These Two Plugin Compatible
Reply With Quote #1

I'm using Spec Info which has an admin command, /spechide, that allows admins to hide themself from speclist. I'm also using Spy Admin that allows admins to hide their admin flag. When an admin uses /spy, it appears at speclist even though it uses /spechide command.
Snake. is offline
Send a message via Skype™ to Snake.
lexzor
Veteran Member
Join Date: Nov 2020
Old 06-03-2022 , 12:34   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #2

try
PHP Code:
#include <amxmodx>

#define PLUGIN_NAME "Spy Admin"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "OciXCrom"

new const szPrefix[] = "^4[SPY]"

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

new 
bool:spy[33]
new 
bool:admin[33]
new 
flags_original[33]
new 
flag_z

new cvar_adminflagcvar_autohide

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    
cvar_adminflag register_cvar("spyadmin_adminflag""e")
    
cvar_autohide register_cvar("spyadmin_autohide""0")
    
    
register_clcmd("say /spy""cmd_spy")
    
register_clcmd("say_team /spy""cmd_spy")
    
register_clcmd("say /spyadmin""cmd_spy")
    
register_clcmd("say_team /spyadmin""cmd_spy")
    
register_clcmd("amx_spyadmin""cmd_spy")
    
    
flag_z read_flags("z")
}

public 
client_putinserver(id)
    
spyadmin_checkadmin(id);
    
public 
spyadmin_checkadmin(id)
{
    
spy[id] = false
    flags_original
[id] = get_user_flags(id)
    
admin[id] = user_has_flag(idcvar_adminflag) ? true false
    
    
if(get_pcvar_num(cvar_autohide) == 1)
    {
        if(
admin[id])
            
spyadmin_removeflags(id)
    }
}

public 
client_infochanged(id
{
    new 
newname[32], oldname[32]
    
    
get_user_info(id"name"newnamecharsmax(newname))
    
get_user_name(idoldnamecharsmax(oldname))
    
    if(!
equali(newnameoldname))
        
spyadmin_checkadmin(id)
}

public 
cmd_spy(id)
{
    if(!
admin[id]) ColorChat(idTEAM_COLOR"%s ^1You have no access to this command."szPrefix)
    else 
spy[id] ? spyadmin_setflags(id) : spyadmin_removeflags(id)
    return 
PLUGIN_HANDLED
}

public 
spyadmin_removeflags(id)
{
    
remove_user_flags(idflags_original[id], 0)
    
set_user_flags(idflag_z0)
    
spy[id] = true
    ColorChat
(idBLUE"%s ^1Spy Mode ^3activated^1."szPrefix)
}

public 
spyadmin_setflags(id)
{
    
remove_user_flags(idflag_z0)
    
set_user_flags(idflags_original[id], 0)
    
spy[id] = false
    ColorChat
(idRED"%s ^1Spy Mode ^3deactivated^1."szPrefix)
}

stock user_has_flag(idcvar)
{
    new 
flags[32]
    
get_flags(get_user_flags(id), flagscharsmax(flags))
    
    new 
vip_flag[2]
    
get_pcvar_string(cvarvip_flagcharsmax(vip_flag))
    
    return (
contain(flagsvip_flag) != -1) ? true false
}

public 
plugin_natives()
{
    
register_native("is_using_spy""native_is_using_spy"0);
}

public 
native_is_using_spy(iPluginIDiParams)
{
    return 
spy[get_param(1)];
}

/* ColorChat */

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    static 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    static 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    
message_begin(typeget_user_msgid("SayText"), _id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    
message_begin(typeget_user_msgid("TeamInfo"), _id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    static 
i;
    
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
        {
            return 
i;
        }
    }

    return -
1;

PHP Code:
/*
SpecInfo v1.3.1
Copyright (C) 2007-2008 Ian (Juan) Cammarata

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
http://ian.cammarata.us
Jan 05 17:39


Description:
This plugin displays a list of spectators currently viewing the live player.
This list is visible to the living player as well as other players currently
spectating that player.  Also spectators can see which movement commands the
the live player is using.         


Commands:
say /speclist    :    Toggle viewing list of spectators.
say /speckeys    :    Toggle viewing keys of player you are spectating.
say /spechide : Immune admins toggle whether or not they're hidden from list.
say /showkeys : View your own keys on screen while alive.


Cvars (First value is default):
si_enabled <1|0> : Enables all plugin functionality.

si_list_enabled <1|0> : Enables spectator list.
si_keys_enabled <1|0> : Enables spectator key view.
si_list_default <1|0> : Default on/off state for spec list when a client joins.
si_keys_default <1|0> : Default on/off state for key view when a client joins.

si_immunity <0|1> : Enables admin immunity; Admins won't show on spec list.

si_msg_r <45|...> : HUD message red value.
si_msg_g <89|...> : HUD message green value.
si_msg_b <116|...> : HUD message blue value.


Notes:
Make sure you place the specinfo.txt file in addons\amxmodx\data\lang


Supported Languages:
English (100%)
Spanish (100%) - Thanks to Mely for checking these.
German (63%) - Thanks to [S]killer for this translation.


Change Log:
Key (+ added | - removed | c changed | f fixed)

v1.3.1 (Jan 5, 2008)
f: Eliminated a bug introduced in 1.3 as well as the occasional index out of bounds error it caused.

v1.3 (Nov 21, 2007)
+: Command "/showkeys" to view your own keys.
c: Minor code optimizations.

v1.2 (Jul 14, 2007)
+: Command "say /spechide" for immune to toggle hidden state.
c: Lots of code optimizations.
f: Always showing keys even when disabled.
f: Hud messaged getting messed up when too many names are on the list. (No seriously, for real this time.)

v1.1 (Jul 06, 2007)
+: Show number of people spectating.
c: Names truncated shorter than 20 chars when lots of players on the list.
c: Spectator list moved further right. (Even further when you're alive.)
f: Hud messaged getting messed up when too many names are on the list. (Same as last time, but it's fixed for good.)

v1.0.1 (June 07, 2007)
f: Hud messaged getting messed up when too many names are on the list.

v1.0 (June 02, 2007)
!Initial Release
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

new const VERSION[ ] = "1.3.1"
new const TRKCVAR[ ] = "specinfo_version"
#define IMMUNE_FLAG ADMIN_IMMUNITY

#define KEYS_STR_LEN 31
#define LIST_STR_LEN 610
#define BOTH_STR_LEN KEYS_STR_LEN + LIST_STR_LEN

//cl_prefs constants
#define FL_LIST    ( 1 << 0 )
#define FL_KEYS    ( 1 << 1 )
#define FL_OWNKEYS ( 1 << 2 )
#define FL_HIDE    ( 1 << 3 )

//cvar pointers
new p_enabledp_list_enabledp_keys_enabledp_list_defaultp_keys_default;
new 
p_redp_grnp_blup_immunity;

//data arrays
new cl_keys[33], cl_prefs[33];
new 
keys_string[33][KEYS_STR_LEN 1], list_string[33][LIST_STR_LEN 1]
new 
cl_names[33][21], spec_ids[33][33];

native is_using_spy(id);

public 
plugin_init( )
{
    
register_plugin"SpecInfo"VERSION"Ian Cammarata" );
    
register_cvarTRKCVARVERSIONFCVAR_SERVER );
    
set_cvar_stringTRKCVARVERSION );
    
    
p_enabled register_cvar"si_enabled""1" );
    
p_list_enabled register_cvar"si_list_enabled""1" );
    
p_keys_enabled register_cvar"si_keys_enabled""1" );
    
p_list_default register_cvar"si_list_default""1" );
    
p_keys_default register_cvar"si_keys_default""1" );
    
p_immunity register_cvar"si_immunity""1" );
    
p_red register_cvar"si_msg_r""45" );
    
p_grn register_cvar"si_msg_g""89" );
    
p_blu register_cvar"si_msg_b""116" );
    
    
register_clcmd"say /speclist""toggle_list"_"Toggle spectator list." );
    
register_clcmd"say /speckeys""toggle_keys"_"Toggle spectator keys." );
    
register_clcmd"say /showkeys""toggle_ownkeys"_"Toggle viewing own keys." );
    
register_clcmd"say /spechide""toggle_hide"IMMUNE_FLAG"Admins toggle being hidden from list." );
    
    
set_task1.0"list_update"___"b" );
    
set_task0.1"keys_update"___"b" );
    
    
register_dictionary"specinfo.txt" );
}

public 
client_connectid )
{
    
cl_prefs[id] = 0;
    if( !
is_user_botid ) )
    {
        if( 
get_pcvar_nump_list_default ) ) cl_prefs[id] |= FL_LIST;
        if( 
get_pcvar_nump_keys_default ) ) cl_prefs[id] |= FL_KEYS;
    }
    
get_user_nameidcl_names[id], 20 );
    return 
PLUGIN_CONTINUE;
}

public 
client_infochangedid )
{
    
get_user_nameidcl_names[id], 20 );
    return 
PLUGIN_CONTINUE;
}

public 
list_update( )
{
    if( 
get_pcvar_nump_enabled ) && get_pcvar_num p_list_enabled ) )
  {
        new 
players[32], numidid2ij;
        for( 
133i++ ) spec_ids[i][0] = 0;
        
        
get_playersplayersnum"bch" );
        for( 
0numi++ )
    {
            
id players[i];
            if( !( 
get_user_flagsid ) & IMMUNE_FLAG && get_pcvar_nump_immunity ) && cl_prefs[id] & FL_HIDE ) )
            {
                
id2 pevidpev_iuser2 );
                if( 
id2 )
                {
                    
spec_idsid2 ][ ]++;
                    
spec_idsid2 ][ spec_idsid2 ][ ] ] = id;
                }
            }
        }
        new 
tmplistLIST_STR_LEN ], tmpstr[41];
        new 
countnamelentmpname[21];
        for( 
i=1i<33i++ )
    {
            
count spec_ids[i][0];
            if(
is_using_spy(count))
                continue;
            if( 
count )
            {
                
namelen = ( LIST_STR_LEN 10 ) / count;
                
clampnamelen1020 );
                
formattmpnamenamelencl_names[i] );
                
formatextmplistLIST_STR_LEN 1"^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t(%d) %s %s:^n"count"%L"tmpname);
                for( 
j=1j<=countj++ )
        {
                    
formattmpnamenamelencl_names[spec_ids[i][j]]);
                    
formatextmpstr40"^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t%s"tmpname );
                    if( 
strlentmplist ) + strlentmpstr ) + ( 11 ) < ( LIST_STR_LEN ) )
                        
formattmplistLIST_STR_LEN 10"%s%s^n"tmplisttmpstr );
                    else
          {
                        
formattmplistLIST_STR_LEN"%s...^n"tmplist );
                        break;
                    }
                }
                if( 
count 10 )
          
formattmplistLIST_STR_LEN,
                        
"%s^n^n^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^tSpecInfo v%s^n",
                        
tmplistVERSION
                    
);
                for( 
j+=0j<10j++ )
          
formattmplistLIST_STR_LEN"%s%s"tmplist"^n" );
                
list_string[i] = tmplist;
            }
        }
        
get_playersplayersnum"ch" );
        for( 
i=0i<numi++ ) clmsgplayers[i] );
    }
    return 
PLUGIN_HANDLED;
}

public 
keys_update( )
{
    if( !
get_pcvar_nump_enabled ) && !get_pcvar_nump_keys_enabled ) ) return;

    new 
players[32], numidi;
    
get_playersplayersnum"a" );
    for( 
0numi++ )
  {
        
id players[i];
        
formatexkeys_string[id], KEYS_STR_LEN" ^n^t^t%s^t^t^t%s^n^t%s %s %s^t^t%s",
            
cl_keys[id] & IN_FORWARD "W" " .",
            
"%L",
            
cl_keys[id] & IN_MOVELEFT "A" ".",
            
cl_keys[id] & IN_BACK "S" ".",
            
cl_keys[id] & IN_MOVERIGHT "D" ".",
            
"%L"
        
);
        
        
//Flags stored in string to fill translation char in clmsg function
        
keys_string[id][0] = 0
        if( 
cl_keys[id] & IN_JUMP keys_string[id][0] |= IN_JUMP;
        if( 
cl_keys[id] & IN_DUCK keys_string[id][0] |= IN_DUCK;
        
        
cl_keys[id] = 0;
    }
    
    new 
id2;
    
get_playersplayersnum"ch" );
    for( 
i=0i<numi++ )
  {
        
id players[i];
        if( 
is_user_aliveid ) )
        {
            if( 
cl_prefs[id] & FL_OWNKEYS clmsgid );
        }
        else
        {
            
id2 pevidpev_iuser2 );
            if( 
cl_prefs[id] & FL_KEYS && id2 && id2 != id clmsgid );
        }
    }

}

public 
server_frame( )
{
    if( 
get_pcvar_nump_enabled ) && get_pcvar_nump_keys_enabled ) )
  {
        new 
players[32], numid;
        
get_playersplayersnum"a" );
        for( new 
0numi++ )
        {
            
id players[i];
            if( 
get_user_buttonid ) & IN_FORWARD )
                
cl_keys[id] |= IN_FORWARD;
            if( 
get_user_buttonid ) & IN_BACK )
                
cl_keys[id] |= IN_BACK;
            if( 
get_user_buttonid ) & IN_MOVELEFT )
                
cl_keys[id] |= IN_MOVELEFT;
            if( 
get_user_buttonid ) & IN_MOVERIGHT )
                
cl_keys[id] |= IN_MOVERIGHT;
            if( 
get_user_buttonid ) & IN_DUCK )
                
cl_keys[id] |= IN_DUCK;
            if( 
get_user_buttonid ) & IN_JUMP )
                
cl_keys[id] |= IN_JUMP;
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
clmsgid )
{
    if( !
id ) return;
    
    new 
prefs cl_prefs[id];
    
    new 
bool:show_own false;
    if( 
is_user_aliveid ) && prefs FL_OWNKEYS show_own true;
    
    if( 
is_user_aliveid ) && !show_own )
  {
        if( 
prefs FL_LIST && spec_ids[id][0] && get_pcvar_nump_list_enabled ) )
        {
            
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        
0.7/*x*/
        
0.1/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
1.1/*hold time*/
        
0.1/*fade in*/
        
0.1/*fade out*/
        
/*chan*/
            
);
            
show_hudmessageidlist_string[id], id"SPECTATING" );
        }
    }
    else
  {
        new 
id2;
        if( 
show_own id2 id;
        else 
id2 pevidpev_iuser2 );
        if( !
id2 ) return;
        
        if( 
prefs FL_LIST || prefs FL_KEYS || show_own )
    {
            
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        
0.48/*x*/
        
0.14/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
prefs FL_KEYS || show_own 0.1 1.1/*hold time*/
        
0.1/*fade in*/
        
0.1/*fade out*/
        
/*chan*/
            
);
            new 
msg[BOTH_STR_LEN 1];
            if( 
prefs FL_LIST && get_pcvar_nump_list_enabled ) && spec_ids[id2][0] )
        
formatex(msg,BOTH_STR_LEN,list_string[id2],id,"SPECTATING");
            else 
msg ="^n^n^n^n^n^n^n^n^n^n^n^n";
            if( 
get_pcvar_nump_keys_enabled ) && ( prefs FL_KEYS || show_own ) )
      {
        
formatmsgBOTH_STR_LEN"%s%s"msgkeys_string[id2][1] );
        
formatmsgBOTH_STR_LENmsg,
                    
idkeys_string[id2][0] & IN_JUMP "JUMP" "LAME",
                    
idkeys_string[id2][0] & IN_DUCK "DUCK" "LAME"
                
);
      }
            
show_hudmessageidmsg );
        }
    }
}

public 
set_hudmsg_flg_notify( )
{
    
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        -
1.0/*x*/
        
0.8/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
3.0/*hold time*/
        
0.0/*fade in*/
        
0.0/*fade out*/
        
-/*chan*/
    
);
}

public 
toggle_listid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_LIST;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_LIST "SPEC_LIST_ENABLED" "SPEC_LIST_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_keysid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_KEYS;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_KEYS "SPEC_KEYS_ENABLED" "SPEC_KEYS_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_ownkeysid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_OWNKEYS;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_OWNKEYS "SPEC_OWNKEYS_ENABLED" "SPEC_OWNKEYS_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_hideidlevelcid )
{
    if( 
cmd_accessidlevelcid) )
    {
        
set_hudmsg_flg_notify( );
        
cl_prefs[id] ^= FL_HIDE;
        
show_hudmessageid"%L"idcl_prefs[id] & FL_HIDE "SPEC_HIDE_ENABLED" "SPEC_HIDE_DISABLED" );
    }
    return 
PLUGIN_HANDLED;


Last edited by lexzor; 06-03-2022 at 12:35.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-04-2022 , 06:34   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #3

That is a very old version of the Spy Admin plugin. This is the latest one - https://www.amxx-bg.info/forum/viewtopic.php?f=32&t=64
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Snake.
Senior Member
Join Date: Jul 2017
Old 06-04-2022 , 08:38   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
That is a very old version of the Spy Admin plugin. This is the latest one - https://www.amxx-bg.info/forum/viewtopic.php?f=32&t=64
That was the one i had been using but rexzor probably edited the old version by mistake if he typed "get source"
Snake. is offline
Send a message via Skype™ to Snake.
Snake.
Senior Member
Join Date: Jul 2017
Old 06-04-2022 , 08:39   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #5

Quote:
Originally Posted by lexzor View Post
try
PHP Code:
#include <amxmodx>

#define PLUGIN_NAME "Spy Admin"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "OciXCrom"

new const szPrefix[] = "^4[SPY]"

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

new 
bool:spy[33]
new 
bool:admin[33]
new 
flags_original[33]
new 
flag_z

new cvar_adminflagcvar_autohide

public plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)
    
    
cvar_adminflag register_cvar("spyadmin_adminflag""e")
    
cvar_autohide register_cvar("spyadmin_autohide""0")
    
    
register_clcmd("say /spy""cmd_spy")
    
register_clcmd("say_team /spy""cmd_spy")
    
register_clcmd("say /spyadmin""cmd_spy")
    
register_clcmd("say_team /spyadmin""cmd_spy")
    
register_clcmd("amx_spyadmin""cmd_spy")
    
    
flag_z read_flags("z")
}

public 
client_putinserver(id)
    
spyadmin_checkadmin(id);
    
public 
spyadmin_checkadmin(id)
{
    
spy[id] = false
    flags_original
[id] = get_user_flags(id)
    
admin[id] = user_has_flag(idcvar_adminflag) ? true false
    
    
if(get_pcvar_num(cvar_autohide) == 1)
    {
        if(
admin[id])
            
spyadmin_removeflags(id)
    }
}

public 
client_infochanged(id
{
    new 
newname[32], oldname[32]
    
    
get_user_info(id"name"newnamecharsmax(newname))
    
get_user_name(idoldnamecharsmax(oldname))
    
    if(!
equali(newnameoldname))
        
spyadmin_checkadmin(id)
}

public 
cmd_spy(id)
{
    if(!
admin[id]) ColorChat(idTEAM_COLOR"%s ^1You have no access to this command."szPrefix)
    else 
spy[id] ? spyadmin_setflags(id) : spyadmin_removeflags(id)
    return 
PLUGIN_HANDLED
}

public 
spyadmin_removeflags(id)
{
    
remove_user_flags(idflags_original[id], 0)
    
set_user_flags(idflag_z0)
    
spy[id] = true
    ColorChat
(idBLUE"%s ^1Spy Mode ^3activated^1."szPrefix)
}

public 
spyadmin_setflags(id)
{
    
remove_user_flags(idflag_z0)
    
set_user_flags(idflags_original[id], 0)
    
spy[id] = false
    ColorChat
(idRED"%s ^1Spy Mode ^3deactivated^1."szPrefix)
}

stock user_has_flag(idcvar)
{
    new 
flags[32]
    
get_flags(get_user_flags(id), flagscharsmax(flags))
    
    new 
vip_flag[2]
    
get_pcvar_string(cvarvip_flagcharsmax(vip_flag))
    
    return (
contain(flagsvip_flag) != -1) ? true false
}

public 
plugin_natives()
{
    
register_native("is_using_spy""native_is_using_spy"0);
}

public 
native_is_using_spy(iPluginIDiParams)
{
    return 
spy[get_param(1)];
}

/* ColorChat */

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    static 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    static 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    
message_begin(typeget_user_msgid("SayText"), _id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    
message_begin(typeget_user_msgid("TeamInfo"), _id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    static 
i;
    
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
        {
            return 
i;
        }
    }

    return -
1;

PHP Code:
/*
SpecInfo v1.3.1
Copyright (C) 2007-2008 Ian (Juan) Cammarata

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
http://ian.cammarata.us
Jan 05 17:39


Description:
This plugin displays a list of spectators currently viewing the live player.
This list is visible to the living player as well as other players currently
spectating that player.  Also spectators can see which movement commands the
the live player is using.         


Commands:
say /speclist    :    Toggle viewing list of spectators.
say /speckeys    :    Toggle viewing keys of player you are spectating.
say /spechide : Immune admins toggle whether or not they're hidden from list.
say /showkeys : View your own keys on screen while alive.


Cvars (First value is default):
si_enabled <1|0> : Enables all plugin functionality.

si_list_enabled <1|0> : Enables spectator list.
si_keys_enabled <1|0> : Enables spectator key view.
si_list_default <1|0> : Default on/off state for spec list when a client joins.
si_keys_default <1|0> : Default on/off state for key view when a client joins.

si_immunity <0|1> : Enables admin immunity; Admins won't show on spec list.

si_msg_r <45|...> : HUD message red value.
si_msg_g <89|...> : HUD message green value.
si_msg_b <116|...> : HUD message blue value.


Notes:
Make sure you place the specinfo.txt file in addons\amxmodx\data\lang


Supported Languages:
English (100%)
Spanish (100%) - Thanks to Mely for checking these.
German (63%) - Thanks to [S]killer for this translation.


Change Log:
Key (+ added | - removed | c changed | f fixed)

v1.3.1 (Jan 5, 2008)
f: Eliminated a bug introduced in 1.3 as well as the occasional index out of bounds error it caused.

v1.3 (Nov 21, 2007)
+: Command "/showkeys" to view your own keys.
c: Minor code optimizations.

v1.2 (Jul 14, 2007)
+: Command "say /spechide" for immune to toggle hidden state.
c: Lots of code optimizations.
f: Always showing keys even when disabled.
f: Hud messaged getting messed up when too many names are on the list. (No seriously, for real this time.)

v1.1 (Jul 06, 2007)
+: Show number of people spectating.
c: Names truncated shorter than 20 chars when lots of players on the list.
c: Spectator list moved further right. (Even further when you're alive.)
f: Hud messaged getting messed up when too many names are on the list. (Same as last time, but it's fixed for good.)

v1.0.1 (June 07, 2007)
f: Hud messaged getting messed up when too many names are on the list.

v1.0 (June 02, 2007)
!Initial Release
*/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

new const VERSION[ ] = "1.3.1"
new const TRKCVAR[ ] = "specinfo_version"
#define IMMUNE_FLAG ADMIN_IMMUNITY

#define KEYS_STR_LEN 31
#define LIST_STR_LEN 610
#define BOTH_STR_LEN KEYS_STR_LEN + LIST_STR_LEN

//cl_prefs constants
#define FL_LIST    ( 1 << 0 )
#define FL_KEYS    ( 1 << 1 )
#define FL_OWNKEYS ( 1 << 2 )
#define FL_HIDE    ( 1 << 3 )

//cvar pointers
new p_enabledp_list_enabledp_keys_enabledp_list_defaultp_keys_default;
new 
p_redp_grnp_blup_immunity;

//data arrays
new cl_keys[33], cl_prefs[33];
new 
keys_string[33][KEYS_STR_LEN 1], list_string[33][LIST_STR_LEN 1]
new 
cl_names[33][21], spec_ids[33][33];

native is_using_spy(id);

public 
plugin_init( )
{
    
register_plugin"SpecInfo"VERSION"Ian Cammarata" );
    
register_cvarTRKCVARVERSIONFCVAR_SERVER );
    
set_cvar_stringTRKCVARVERSION );
    
    
p_enabled register_cvar"si_enabled""1" );
    
p_list_enabled register_cvar"si_list_enabled""1" );
    
p_keys_enabled register_cvar"si_keys_enabled""1" );
    
p_list_default register_cvar"si_list_default""1" );
    
p_keys_default register_cvar"si_keys_default""1" );
    
p_immunity register_cvar"si_immunity""1" );
    
p_red register_cvar"si_msg_r""45" );
    
p_grn register_cvar"si_msg_g""89" );
    
p_blu register_cvar"si_msg_b""116" );
    
    
register_clcmd"say /speclist""toggle_list"_"Toggle spectator list." );
    
register_clcmd"say /speckeys""toggle_keys"_"Toggle spectator keys." );
    
register_clcmd"say /showkeys""toggle_ownkeys"_"Toggle viewing own keys." );
    
register_clcmd"say /spechide""toggle_hide"IMMUNE_FLAG"Admins toggle being hidden from list." );
    
    
set_task1.0"list_update"___"b" );
    
set_task0.1"keys_update"___"b" );
    
    
register_dictionary"specinfo.txt" );
}

public 
client_connectid )
{
    
cl_prefs[id] = 0;
    if( !
is_user_botid ) )
    {
        if( 
get_pcvar_nump_list_default ) ) cl_prefs[id] |= FL_LIST;
        if( 
get_pcvar_nump_keys_default ) ) cl_prefs[id] |= FL_KEYS;
    }
    
get_user_nameidcl_names[id], 20 );
    return 
PLUGIN_CONTINUE;
}

public 
client_infochangedid )
{
    
get_user_nameidcl_names[id], 20 );
    return 
PLUGIN_CONTINUE;
}

public 
list_update( )
{
    if( 
get_pcvar_nump_enabled ) && get_pcvar_num p_list_enabled ) )
  {
        new 
players[32], numidid2ij;
        for( 
133i++ ) spec_ids[i][0] = 0;
        
        
get_playersplayersnum"bch" );
        for( 
0numi++ )
    {
            
id players[i];
            if( !( 
get_user_flagsid ) & IMMUNE_FLAG && get_pcvar_nump_immunity ) && cl_prefs[id] & FL_HIDE ) )
            {
                
id2 pevidpev_iuser2 );
                if( 
id2 )
                {
                    
spec_idsid2 ][ ]++;
                    
spec_idsid2 ][ spec_idsid2 ][ ] ] = id;
                }
            }
        }
        new 
tmplistLIST_STR_LEN ], tmpstr[41];
        new 
countnamelentmpname[21];
        for( 
i=1i<33i++ )
    {
            
count spec_ids[i][0];
            if(
is_using_spy(count))
                continue;
            if( 
count )
            {
                
namelen = ( LIST_STR_LEN 10 ) / count;
                
clampnamelen1020 );
                
formattmpnamenamelencl_names[i] );
                
formatextmplistLIST_STR_LEN 1"^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t(%d) %s %s:^n"count"%L"tmpname);
                for( 
j=1j<=countj++ )
        {
                    
formattmpnamenamelencl_names[spec_ids[i][j]]);
                    
formatextmpstr40"^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t%s"tmpname );
                    if( 
strlentmplist ) + strlentmpstr ) + ( 11 ) < ( LIST_STR_LEN ) )
                        
formattmplistLIST_STR_LEN 10"%s%s^n"tmplisttmpstr );
                    else
          {
                        
formattmplistLIST_STR_LEN"%s...^n"tmplist );
                        break;
                    }
                }
                if( 
count 10 )
          
formattmplistLIST_STR_LEN,
                        
"%s^n^n^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^tSpecInfo v%s^n",
                        
tmplistVERSION
                    
);
                for( 
j+=0j<10j++ )
          
formattmplistLIST_STR_LEN"%s%s"tmplist"^n" );
                
list_string[i] = tmplist;
            }
        }
        
get_playersplayersnum"ch" );
        for( 
i=0i<numi++ ) clmsgplayers[i] );
    }
    return 
PLUGIN_HANDLED;
}

public 
keys_update( )
{
    if( !
get_pcvar_nump_enabled ) && !get_pcvar_nump_keys_enabled ) ) return;

    new 
players[32], numidi;
    
get_playersplayersnum"a" );
    for( 
0numi++ )
  {
        
id players[i];
        
formatexkeys_string[id], KEYS_STR_LEN" ^n^t^t%s^t^t^t%s^n^t%s %s %s^t^t%s",
            
cl_keys[id] & IN_FORWARD "W" " .",
            
"%L",
            
cl_keys[id] & IN_MOVELEFT "A" ".",
            
cl_keys[id] & IN_BACK "S" ".",
            
cl_keys[id] & IN_MOVERIGHT "D" ".",
            
"%L"
        
);
        
        
//Flags stored in string to fill translation char in clmsg function
        
keys_string[id][0] = 0
        if( 
cl_keys[id] & IN_JUMP keys_string[id][0] |= IN_JUMP;
        if( 
cl_keys[id] & IN_DUCK keys_string[id][0] |= IN_DUCK;
        
        
cl_keys[id] = 0;
    }
    
    new 
id2;
    
get_playersplayersnum"ch" );
    for( 
i=0i<numi++ )
  {
        
id players[i];
        if( 
is_user_aliveid ) )
        {
            if( 
cl_prefs[id] & FL_OWNKEYS clmsgid );
        }
        else
        {
            
id2 pevidpev_iuser2 );
            if( 
cl_prefs[id] & FL_KEYS && id2 && id2 != id clmsgid );
        }
    }

}

public 
server_frame( )
{
    if( 
get_pcvar_nump_enabled ) && get_pcvar_nump_keys_enabled ) )
  {
        new 
players[32], numid;
        
get_playersplayersnum"a" );
        for( new 
0numi++ )
        {
            
id players[i];
            if( 
get_user_buttonid ) & IN_FORWARD )
                
cl_keys[id] |= IN_FORWARD;
            if( 
get_user_buttonid ) & IN_BACK )
                
cl_keys[id] |= IN_BACK;
            if( 
get_user_buttonid ) & IN_MOVELEFT )
                
cl_keys[id] |= IN_MOVELEFT;
            if( 
get_user_buttonid ) & IN_MOVERIGHT )
                
cl_keys[id] |= IN_MOVERIGHT;
            if( 
get_user_buttonid ) & IN_DUCK )
                
cl_keys[id] |= IN_DUCK;
            if( 
get_user_buttonid ) & IN_JUMP )
                
cl_keys[id] |= IN_JUMP;
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
clmsgid )
{
    if( !
id ) return;
    
    new 
prefs cl_prefs[id];
    
    new 
bool:show_own false;
    if( 
is_user_aliveid ) && prefs FL_OWNKEYS show_own true;
    
    if( 
is_user_aliveid ) && !show_own )
  {
        if( 
prefs FL_LIST && spec_ids[id][0] && get_pcvar_nump_list_enabled ) )
        {
            
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        
0.7/*x*/
        
0.1/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
1.1/*hold time*/
        
0.1/*fade in*/
        
0.1/*fade out*/
        
/*chan*/
            
);
            
show_hudmessageidlist_string[id], id"SPECTATING" );
        }
    }
    else
  {
        new 
id2;
        if( 
show_own id2 id;
        else 
id2 pevidpev_iuser2 );
        if( !
id2 ) return;
        
        if( 
prefs FL_LIST || prefs FL_KEYS || show_own )
    {
            
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        
0.48/*x*/
        
0.14/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
prefs FL_KEYS || show_own 0.1 1.1/*hold time*/
        
0.1/*fade in*/
        
0.1/*fade out*/
        
/*chan*/
            
);
            new 
msg[BOTH_STR_LEN 1];
            if( 
prefs FL_LIST && get_pcvar_nump_list_enabled ) && spec_ids[id2][0] )
        
formatex(msg,BOTH_STR_LEN,list_string[id2],id,"SPECTATING");
            else 
msg ="^n^n^n^n^n^n^n^n^n^n^n^n";
            if( 
get_pcvar_nump_keys_enabled ) && ( prefs FL_KEYS || show_own ) )
      {
        
formatmsgBOTH_STR_LEN"%s%s"msgkeys_string[id2][1] );
        
formatmsgBOTH_STR_LENmsg,
                    
idkeys_string[id2][0] & IN_JUMP "JUMP" "LAME",
                    
idkeys_string[id2][0] & IN_DUCK "DUCK" "LAME"
                
);
      }
            
show_hudmessageidmsg );
        }
    }
}

public 
set_hudmsg_flg_notify( )
{
    
set_hudmessage(
        
get_pcvar_nump_red ),
        
get_pcvar_nump_grn ),
        
get_pcvar_nump_blu ),
        -
1.0/*x*/
        
0.8/*y*/
        
0/*fx*/
        
0.0/*fx time*/
        
3.0/*hold time*/
        
0.0/*fade in*/
        
0.0/*fade out*/
        
-/*chan*/
    
);
}

public 
toggle_listid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_LIST;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_LIST "SPEC_LIST_ENABLED" "SPEC_LIST_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_keysid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_KEYS;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_KEYS "SPEC_KEYS_ENABLED" "SPEC_KEYS_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_ownkeysid )
{
    
set_hudmsg_flg_notify( );
    
cl_prefs[id] ^= FL_OWNKEYS;
    
show_hudmessageid"%L"idcl_prefs[id] & FL_OWNKEYS "SPEC_OWNKEYS_ENABLED" "SPEC_OWNKEYS_DISABLED" );
    return 
PLUGIN_HANDLED;
}

public 
toggle_hideidlevelcid )
{
    if( 
cmd_accessidlevelcid) )
    {
        
set_hudmsg_flg_notify( );
        
cl_prefs[id] ^= FL_HIDE;
        
show_hudmessageid"%L"idcl_prefs[id] & FL_HIDE "SPEC_HIDE_ENABLED" "SPEC_HIDE_DISABLED" );
    }
    return 
PLUGIN_HANDLED;

Thanks for your exertion but that was the old version :/
Snake. is offline
Send a message via Skype™ to Snake.
lexzor
Veteran Member
Join Date: Nov 2020
Old 06-04-2022 , 15:22   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <cromchat>

native agroups_update_user_group(id)
native cm_update_player_data(id)

new const 
PLUGIN_VERSION[] = "2.2"
const Float:REFRESH_DELAY 0.1

new bool:g_bSpy[33], bool:g_bAdmin[33]
new 
g_iOriginalFlags[33], g_iDefaultFlag
new g_pAdminFlagg_pAutoHide
new g_iAutoHideg_iAdminFlag

new bool:g_bChatManagerbool:g_bAdminGroups

new const g_szCommands[][] = { "say /spy""say_team /spy""say /spyadmin""say_team /spyadmin""amx_spy""amx_spyadmin" }

public 
plugin_init()
{
    
register_plugin("Spy Admin"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXSpyAdmin"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_dictionary("SpyAdmin.txt")

    if(
LibraryExists("agroups.inc"LibType_Library))
    {
        
g_bAdminGroups true
    
}

    if(
LibraryExists("chatmanager"LibType_Library))
    {
        
g_bChatManager true
    
}

    
g_pAdminFlag register_cvar("spyadmin_adminflag""e")
    
g_pAutoHide register_cvar("spyadmin_autohide""0")

    for(new 
isizeof(g_szCommands); i++)
    {
        
register_clcmd(g_szCommands[i], "CmdSpy")
    }

    
CC_SetPrefix("&x04[SPY]")
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}

public 
module_filter(const szLibrary[])
{
    return (
equal(szLibrary"chatmanager") || equal(szLibrary"agroups")) ? PLUGIN_HANDLED PLUGIN_CONTINUE
}

public 
native_filter(const szNative[], idiTrap)
{
    return (!
iTrap && (equal(szNative"agroups_update_user_group") || equal(szNative"cm_update_player_data"))) ? PLUGIN_HANDLED PLUGIN_CONTINUE
}

public 
plugin_cfg()
{
    new 
szFlags[32]
    
get_pcvar_string(g_pAdminFlagszFlagscharsmax(szFlags))
    
g_iAdminFlag read_flags(szFlags)
    
get_cvar_string("amx_default_access"szFlagscharsmax(szFlags))
    
g_iDefaultFlag read_flags(szFlags)
    
g_iAutoHide get_pcvar_num(g_pAutoHide)
}

public 
client_putinserver(id)
{
    
spyadmin_checkadmin(id)
}

public 
spyadmin_checkadmin(id)
{
    
g_bSpy[id] = false
    g_iOriginalFlags
[id] = get_user_flags(id)
    
g_bAdmin[id] = bool:(get_user_flags(id) & g_iAdminFlag)

    if(
g_iAutoHide && g_bAdmin[id])
    {
        
spyadmin_removeflags(id)
    }
}

public 
client_infochanged(id)
{
    static 
szNewName[32], szOldName[32]
    
get_user_info(id"name"szNewNamecharsmax(szNewName))
    
get_user_name(idszOldNamecharsmax(szOldName))

    if(!
equal(szNewNameszOldName))
    {
        
set_task(REFRESH_DELAY"spyadmin_checkadmin"id)
    }
}

public 
CmdSpy(id)
{
    if(!
g_bAdmin[id])
    {
        
CC_SendMessage(id"%L"id"SPYADMIN_NOACCESS")
    }
    else
    {
        
g_bSpy[id] ? spyadmin_setflags(id) : spyadmin_removeflags(id)
    }

    
client_print(idprint_chat"asd you")

    if(
g_bAdminGroups)
    {
        
client_print(idprint_chat"updating you")
        
agroups_update_user_group(id)
    }

    if(
g_bChatManager)
    {
        
cm_update_player_data(id)
    }

    return 
PLUGIN_HANDLED
}

public 
spyadmin_removeflags(id)
{
    
remove_user_flags(idg_iOriginalFlags[id], 0)
    
set_user_flags(idg_iDefaultFlag0)
    
CC_SendMessage(id"%L"id"SPYADMIN_ACTIVATED")
    
g_bSpy[id] = true
}

public 
spyadmin_setflags(id)
{
    
remove_user_flags(idg_iDefaultFlag0)
    
set_user_flags(idg_iOriginalFlags[id], 0)
    
CC_SendMessage(id"%L"id"SPYADMIN_DEACTIVATED")
    
g_bSpy[id] = false
}

public 
plugin_natives()
{
    
register_native("is_using_spy""native_is_using_spy"0);
}

public 
native_is_using_spy(iPluginIDiParams)
{
    return 
g_bSpy[get_param(1)];

lexzor is offline
Snake.
Senior Member
Join Date: Jul 2017
Old 06-04-2022 , 17:08   Re: [Request] Making These Two Plugin Compatible
Reply With Quote #7

Quote:
Originally Posted by lexzor View Post
PHP Code:
#include <amxmodx>
#include <cromchat>

native agroups_update_user_group(id)
native cm_update_player_data(id)

new const 
PLUGIN_VERSION[] = "2.2"
const Float:REFRESH_DELAY 0.1

new bool:g_bSpy[33], bool:g_bAdmin[33]
new 
g_iOriginalFlags[33], g_iDefaultFlag
new g_pAdminFlagg_pAutoHide
new g_iAutoHideg_iAdminFlag

new bool:g_bChatManagerbool:g_bAdminGroups

new const g_szCommands[][] = { "say /spy""say_team /spy""say /spyadmin""say_team /spyadmin""amx_spy""amx_spyadmin" }

public 
plugin_init()
{
    
register_plugin("Spy Admin"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXSpyAdmin"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_dictionary("SpyAdmin.txt")

    if(
LibraryExists("agroups.inc"LibType_Library))
    {
        
g_bAdminGroups true
    
}

    if(
LibraryExists("chatmanager"LibType_Library))
    {
        
g_bChatManager true
    
}

    
g_pAdminFlag register_cvar("spyadmin_adminflag""e")
    
g_pAutoHide register_cvar("spyadmin_autohide""0")

    for(new 
isizeof(g_szCommands); i++)
    {
        
register_clcmd(g_szCommands[i], "CmdSpy")
    }

    
CC_SetPrefix("&x04[SPY]")
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}

public 
module_filter(const szLibrary[])
{
    return (
equal(szLibrary"chatmanager") || equal(szLibrary"agroups")) ? PLUGIN_HANDLED PLUGIN_CONTINUE
}

public 
native_filter(const szNative[], idiTrap)
{
    return (!
iTrap && (equal(szNative"agroups_update_user_group") || equal(szNative"cm_update_player_data"))) ? PLUGIN_HANDLED PLUGIN_CONTINUE
}

public 
plugin_cfg()
{
    new 
szFlags[32]
    
get_pcvar_string(g_pAdminFlagszFlagscharsmax(szFlags))
    
g_iAdminFlag read_flags(szFlags)
    
get_cvar_string("amx_default_access"szFlagscharsmax(szFlags))
    
g_iDefaultFlag read_flags(szFlags)
    
g_iAutoHide get_pcvar_num(g_pAutoHide)
}

public 
client_putinserver(id)
{
    
spyadmin_checkadmin(id)
}

public 
spyadmin_checkadmin(id)
{
    
g_bSpy[id] = false
    g_iOriginalFlags
[id] = get_user_flags(id)
    
g_bAdmin[id] = bool:(get_user_flags(id) & g_iAdminFlag)

    if(
g_iAutoHide && g_bAdmin[id])
    {
        
spyadmin_removeflags(id)
    }
}

public 
client_infochanged(id)
{
    static 
szNewName[32], szOldName[32]
    
get_user_info(id"name"szNewNamecharsmax(szNewName))
    
get_user_name(idszOldNamecharsmax(szOldName))

    if(!
equal(szNewNameszOldName))
    {
        
set_task(REFRESH_DELAY"spyadmin_checkadmin"id)
    }
}

public 
CmdSpy(id)
{
    if(!
g_bAdmin[id])
    {
        
CC_SendMessage(id"%L"id"SPYADMIN_NOACCESS")
    }
    else
    {
        
g_bSpy[id] ? spyadmin_setflags(id) : spyadmin_removeflags(id)
    }

    
client_print(idprint_chat"asd you")

    if(
g_bAdminGroups)
    {
        
client_print(idprint_chat"updating you")
        
agroups_update_user_group(id)
    }

    if(
g_bChatManager)
    {
        
cm_update_player_data(id)
    }

    return 
PLUGIN_HANDLED
}

public 
spyadmin_removeflags(id)
{
    
remove_user_flags(idg_iOriginalFlags[id], 0)
    
set_user_flags(idg_iDefaultFlag0)
    
CC_SendMessage(id"%L"id"SPYADMIN_ACTIVATED")
    
g_bSpy[id] = true
}

public 
spyadmin_setflags(id)
{
    
remove_user_flags(idg_iDefaultFlag0)
    
set_user_flags(idg_iOriginalFlags[id], 0)
    
CC_SendMessage(id"%L"id"SPYADMIN_DEACTIVATED")
    
g_bSpy[id] = false
}

public 
plugin_natives()
{
    
register_native("is_using_spy""native_is_using_spy"0);
}

public 
native_is_using_spy(iPluginIDiParams)
{
    return 
g_bSpy[get_param(1)];

Thanks!
Snake. is offline
Send a message via Skype™ to Snake.
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 11:29.


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