Raised This Month: $ Target: $400
 0% 

How to get admin's information from users.ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-27-2015 , 19:54   Re: How to get admin's information from users.ini
Reply With Quote #1

As long as you consistently store the users name in the first field (I don't) then this can work.
Code:
; Format of admin account:
; <name|ip|steamid> <password> <access flags> <account flags>

; "STEAM_0:0:123456" "" "abcdefghijklmnopqrstu" "ce"
; "123.45.67.89" "" "abcdefghijklmnopqrstu" "de"
If you find your MOTD is getting cut-off before showing all admins, increase the size of MOTD_BUFFER. If you have more than 20 admins, increase MAX_ADMINS accordingly.
PHP Code:
#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.1";

const 
MAX_ADMINS 20;
const 
MOTD_BUFFER 1024;

public 
plugin_init() 
{
    
register_plugin"Show Admins.ini" Version "bugsy" );
    
    
register_clcmd"say admins" "ShowAdmins" );
}

public 
ShowAdminsid )
{    
    new 
szAdminsMAX_ADMINS ][ ][ 32 ] , szMOTDMOTD_BUFFER ] , iNumAdmins;
    
    
iNumAdmins GetAdminInfoszAdmins sizeofszAdmins ) , charsmaxszAdmins[][] ) );
    
BuildMOTDszMOTD charsmaxszMOTD ) , szAdmins iNumAdmins );
    
    
show_motdid szMOTD );
}

GetAdminInfoszAdminArray[][][] , iMaxAdmins iMaxChars )
{
    new 
szUsersFile64 ] , iFile  szLine64 ] , iAdminIndex szTmp];
    
    
copyszUsersFileget_configsdirszUsersFile charsmaxszUsersFile ) ) ] , charsmaxszUsersFile ) , "/users.ini" );
    
    if ( ( 
iFile fopenszUsersFile "r" ) ) )
    {
        while ( ( 
iAdminIndex iMaxAdmins ) && fgetsiFile szLine charsmaxszLine ) ) )
        {
            if ( 
szLine] && szLine] != ';' && szLine] != '^n' )
            {
                
parseszLine szAdminArrayiAdminIndex ][ ] , iMaxChars szTmp szAdminArrayiAdminIndex ][ ] , iMaxChars );
                
iAdminIndex++;
            }
        }
        
        
fcloseiFile );
    }
    
    return 
iAdminIndex;
}

BuildMOTDszMOTD[] , iMaxChars , const szAdminArray[][][] , iNumAdmins )
{
    new 
iPos copyszMOTD iMaxChars "<html><b><font size=5>Server Admins</font></b><br><table style=^"width:100%^"><tr><th align=^"left^">Name</th><th align=^"left^">Flags</th></tr>" );
    
    for ( new 
iNumAdmins i++ )
        
iPos += formatexszMOTDiPos ] , iMaxChars iPos "<tr><td>%s</td><td>%s</td></tr>" szAdminArray][ ] , szAdminArray][ ] );
    
    
copyszMOTDiPos ] , iMaxChars iPos "</table></body></html>" );

__________________

Last edited by Bugsy; 05-27-2015 at 22:48.
Bugsy 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 20:05.


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