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 ShowAdmins( id )
{
new szAdmins[ MAX_ADMINS ][ 2 ][ 32 ] , szMOTD[ MOTD_BUFFER ] , iNumAdmins;
iNumAdmins = GetAdminInfo( szAdmins , sizeof( szAdmins ) , charsmax( szAdmins[][] ) );
BuildMOTD( szMOTD , charsmax( szMOTD ) , szAdmins , iNumAdmins );
show_motd( id , szMOTD );
}
GetAdminInfo( szAdminArray[][][] , iMaxAdmins , iMaxChars )
{
new szUsersFile[ 64 ] , iFile , szLine[ 64 ] , iAdminIndex , szTmp[ 2 ];
copy( szUsersFile[ get_configsdir( szUsersFile , charsmax( szUsersFile ) ) ] , charsmax( szUsersFile ) , "/users.ini" );
if ( ( iFile = fopen( szUsersFile , "r" ) ) )
{
while ( ( iAdminIndex < iMaxAdmins ) && fgets( iFile , szLine , charsmax( szLine ) ) )
{
if ( szLine[ 0 ] && szLine[ 0 ] != ';' && szLine[ 0 ] != '^n' )
{
parse( szLine , szAdminArray[ iAdminIndex ][ 0 ] , iMaxChars , szTmp , 1 , szAdminArray[ iAdminIndex ][ 1 ] , iMaxChars );
iAdminIndex++;
}
}
fclose( iFile );
}
return iAdminIndex;
}
BuildMOTD( szMOTD[] , iMaxChars , const szAdminArray[][][] , iNumAdmins )
{
new iPos = copy( szMOTD , 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 i = 0 ; i < iNumAdmins ; i++ )
iPos += formatex( szMOTD[ iPos ] , iMaxChars - iPos , "<tr><td>%s</td><td>%s</td></tr>" , szAdminArray[ i ][ 0 ] , szAdminArray[ i ][ 1 ] );
copy( szMOTD[ iPos ] , iMaxChars - iPos , "</table></body></html>" );
}
__________________