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

[Req] Make these two plugin work together


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snake.
Senior Member
Join Date: Jul 2017
Old 04-22-2019 , 17:13   [Req] Make these two plugin work together
Reply With Quote #1

Hello. I'm using Admin Groups plugin and also Admin Spy plugin. The problem is, when i spy my admin, i'm still being showed in admin groups as an Admin.Can someone fix dat ?
Snake. is offline
Send a message via Skype™ to Snake.
HiDeath
Senior Member
Join Date: Aug 2018
Location: Tunisia
Old 04-23-2019 , 06:25   Re: [Req] Make these two plugin work together
Reply With Quote #2

the only solution i can imagine is to merge the 2 plugins and remove your name from menu while you are in spec ( bool var )
but yeah , that needs some work
HiDeath is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-24-2019 , 13:08   Re: [Req] Make these two plugin work together
Reply With Quote #3

The best solution would be if they add a forward that's called when the player's admin flags are changed.
This should work for crx_spyadmin.sma:

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)
    }

    if(
g_bAdminGroups)
    {
        
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

I'll update the main plugin too if there aren't any problems.
__________________

Last edited by OciXCrom; 04-25-2019 at 08:11.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Snake.
Senior Member
Join Date: Jul 2017
Old 04-24-2019 , 16:37   Re: [Req] Make these two plugin work together
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
The best solution would be if they add a forward that's called when the player's admin flags are changed.
This should work for crx_spyadmin.sma:

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"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)
    }

    if(
g_bAdminGroups)
    {
        
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

I'll update the main plugin too if there aren't any problems.
Did not work, i still seem in spy mode.
Snake. is offline
Send a message via Skype™ to Snake.
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-25-2019 , 08:11   Re: [Req] Make these two plugin work together
Reply With Quote #5

I updated the code, try now.
__________________

Last edited by OciXCrom; 04-25-2019 at 08:11.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Snake.
Senior Member
Join Date: Jul 2017
Old 04-25-2019 , 11:17   Re: [Req] Make these two plugin work together
Reply With Quote #6

Quote:
Originally Posted by OciXCrom View Post
I updated the code, try now.
It worked, thank you!
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 12:43.


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