Raised This Month: $208 Target: $400
 52% 

Getting a list of ALL admins, including non-present ones


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AdamR
Senior Member
Join Date: Dec 2006
Location: Cardiff, South Wales
Old 07-08-2010 , 16:06   Getting a list of ALL admins, including non-present ones
Reply With Quote #1

Hi,

I'm trying to retrieve a list of all administrators stored in AMXX's dynamic list. I see that in amxmodx.inc there is a function admins_lookup() to do this, but perhaps I'm using it wrong:
PHP Code:
static iAdmins;
static 
fFlags;
static 
szAuthData[44];

new 
szAdmins[MAX_ADMINS_LENGTH]
format(szAdminsMAX_ADMINS_LENGTH"VALVE_ID_LOOPBACK")

iAdmins admins_num();

for (new 
0iAdminsi++)
{
    
fFlags admins_lookup(iAdminProp_Flags);
    
admins_lookup(iAdminProp_AuthszAuthDatasizeof(szAuthData) - 1);

    if (
fFlags FLAG_AUTHID || fFlags FLAG_IP)
        
format(szAdminsMAX_ADMINS_LENGTH"%s;%s"szAdminsszAuthData)

Basically I'm trying to get all administrators into a string, split by a semi-colon. It should not matter if the administrators are stored in a file or SQL table as I want to read them after they are loaded by the core.

The main issue I'm finding is iAdmins is always 0 -- so the admin_num() function isn't returning anything, or is being called after the core plug-in has loaded the list of administrators.
__________________
Thanks,

Adam Reece - Sven Co-op team.
AdamR is offline
Send a message via Skype™ to AdamR
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-08-2010 , 17:39   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #2

Quote:
Originally Posted by AdamR View Post
The main issue I'm finding is iAdmins is always 0 -- so the admin_num() function isn't returning anything, or is being called after the core plug-in has loaded the list of administrators.
Why don't you test this theory?
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-08-2010 , 20:44   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #3

When exactly are you attempting to use that code. I just tested it (calling at plugin_init) and it is returning admins for me...or perhaps I am not understanding your objective/question. I don't use SQL or anything for admins, just users.ini.

PHP Code:
const MAX_ADMINS_LENGTH 1000;

public 
plugin_init() 
{
    
LoadAdmins();
}

public 
LoadAdmins()
{
    static 
iAdmins;
    static 
fFlags;
    static 
szAuthData[44];
    
    new 
szAdmins[MAX_ADMINS_LENGTH]
    
format(szAdminsMAX_ADMINS_LENGTH"VALVE_ID_LOOPBACK")
    
    
iAdmins admins_num();
    
    for (new 
0iAdminsi++)
    {
        
fFlags admins_lookup(iAdminProp_Flags);
        
admins_lookup(iAdminProp_AuthszAuthDatasizeof(szAuthData) - 1);
    
        if (
fFlags FLAG_AUTHID || fFlags FLAG_IP)
            
format(szAdminsMAX_ADMINS_LENGTH"%s;%s"szAdminsszAuthData)
    }
    
    
server_printszAdmins );

Result (I am the only admin on my test server)
Code:
VALVE_ID_LOOPBACK;loopback;STEAM_0:0:XXXXX
__________________

Last edited by Bugsy; 07-10-2010 at 00:09.
Bugsy is offline
AdamR
Senior Member
Join Date: Dec 2006
Location: Cardiff, South Wales
Old 07-09-2010 , 06:29   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #4

It's probably because I'm using SQL tables, perhaps there is a delay before the core plug-in has finished loading the admins from it.

Perhaps I should attempt to call it again after 15 seconds if it doesn't find any admins the first time round.
__________________
Thanks,

Adam Reece - Sven Co-op team.
AdamR is offline
Send a message via Skype™ to AdamR
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 09:53   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #5

When exactly are you trying to execute the code?
__________________
Bugsy is offline
AdamR
Senior Member
Join Date: Dec 2006
Location: Cardiff, South Wales
Old 07-09-2010 , 09:54   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #6

plugin_init() calls ReadAdmins().

I've fixed this by trying again 5 seconds later after a fail, though it sets a global bool to true so it only tries again once.
__________________
Thanks,

Adam Reece - Sven Co-op team.
AdamR is offline
Send a message via Skype™ to AdamR
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 10:16   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #7

Quote:
Originally Posted by AdamR View Post
plugin_init() calls ReadAdmins().

I've fixed this by trying again 5 seconds later after a fail, though it sets a global bool to true so it only tries again once.
Try doing it at plugin_cfg()?
__________________
Bugsy is offline
AdamR
Senior Member
Join Date: Dec 2006
Location: Cardiff, South Wales
Old 07-09-2010 , 12:10   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #8

Does plugin_cfg() run after admins have been loaded? (even from SQL)
__________________
Thanks,

Adam Reece - Sven Co-op team.
AdamR is offline
Send a message via Skype™ to AdamR
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 14:45   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #9

I have no idea if it makes any difference for what you're doing but it never hurts to try.
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-09-2010 , 20:33   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #10

Looks to me like it loads at the same time that it would if it wasn't SQL.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 05:10.


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