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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 07-09-2010 , 21:35   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #11

This should display every admin on your server.

PHP Code:
#include <amxmodx>

public plugin_init()
    
register_plugin("Admin Lookup""1.0""Spunky")

public 
plugin_cfg()
{
    new 
szFilePath[64]
    
get_configsdir(szFilePath63)
    
add(szFilePath63"/users.ini")

    new 
iFileSize file_size(szFilePath1)
    new 
szBuffer[128], iLen
    
new szAuth[36]

    
server_print("Admins^n----------")

    for (new 
ijiFileSizei++)
    {
        
read_file(szFilePathiszBuffer127iLen)

        if (
szBuffer[0] == ';')
            continue

        
parse(szBufferszAuth35szBuffer127szBuffer127szBuffer127)
        
server_print("%d. %s", ++jszAuth)
    }

Spunky is offline
Send a message via AIM to Spunky
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-09-2010 , 21:50   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #12

Quote:
Originally Posted by Spunky View Post
This should display every admin on your server.
Quote:
Originally Posted by AdamR View Post
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.
__________________
Bugsy is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 07-09-2010 , 23:07   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #13

Oh.
Spunky is offline
Send a message via AIM to Spunky
AdamR
Senior Member
Join Date: Dec 2006
Location: Cardiff, South Wales
Old 07-10-2010 , 07:36   Re: Getting a list of ALL admins, including non-present ones
Reply With Quote #14

This does the trick
Code:
/* Messages */

#define MSG_FOUND_ADMINS		"administrators found."
#define MSG_NO_ADMINS			"No administrators found."
#define MSG_NO_ADMINS_TRYING_AGAIN	"No administrators found -- will try again in"



/* Definitions */

#define MAX_ADMINS_LENGTH	512
#define RETRY_DELAY		5.0



/* Globals */

new bool:g_triedAgain



/* Pointer-CVAR's */

new p_Admins



/* Functions */

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VER, "Adam Reece")

	p_Admins = register_cvar("sv_admins", "VALVE_ID_LOOPBACK")

	register_srvcmd("amx_plugin_info", "PrintPluginInfo")

	g_triedAgain = false
	ReadAdmins()
}

public PrintPluginInfo()
{
	log_message("%s v%s, last updated %s", PLUGIN_NAME, PLUGIN_VER, PLUGIN_LASTUPDATE)
}

public ReadAdmins()
{
	static iAdmins;
	static fFlags;
	static szAuthData[44];

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

	iAdmins = admins_num();

	for (new i = 0; i < iAdmins; i++)
	{
		fFlags = admins_lookup(i, AdminProp_Flags);
		admins_lookup(i, AdminProp_Auth, szAuthData, sizeof(szAuthData) - 1);

		if (fFlags & FLAG_AUTHID || fFlags & FLAG_IP)
			format(szAdmins, MAX_ADMINS_LENGTH, "%s;%s", szAdmins, szAuthData)
	}

	if (iAdmins > 0)
	{
		set_pcvar_string(p_Admins, szAdmins)
		log_message("[%s] %d %s", PLUGIN_SHORT, iAdmins, MSG_FOUND_ADMINS)
	}
	else
	{
		if (!g_triedAgain)
		{
			new iRetryTask = random_num(1, 65535)
			while (task_exists(iRetryTask, 1) == 1)
				iRetryTask = random_num(1, 65535)

			set_task(RETRY_DELAY, "ReadAdmins", iRetryTask)

			g_triedAgain = true
			log_message("[%s] %s %d.", PLUGIN_SHORT, MSG_NO_ADMINS_TRYING_AGAIN, RETRY_DELAY)
		}
		else
			log_message("[%s] %s", PLUGIN_SHORT, MSG_NO_ADMINS)
	}
}
Thanks for your help all
__________________
Thanks,

Adam Reece - Sven Co-op team.
AdamR is offline
Send a message via Skype™ to AdamR
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 05:24.


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