AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   How to get admin's information from users.ini (https://forums.alliedmods.net/showthread.php?t=263536)

BaD CopY 05-27-2015 13:18

How to get admin's information from users.ini
 
Hello everyone,

I'll like if someone can make tutorial and an example code for following:

When any admin or player type: /admins in chat, then thet person can see motd with all admins from users.ini file. Example:

http://www.dodaj.rs/f/3V/hq/2S9mNJn/motd.png

And I want to know is possible to change page in motd?

wickedd 05-27-2015 18:40

Re: How to get admin's information from users.ini
 
1.Post your question in the right forum.
2.Search the forum. No one is going to write tutorial for you when there's 100s of examples on the forum.

Bugsy 05-27-2015 19:54

Re: How to get admin's information from users.ini
 
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>" );



BaD CopY 05-28-2015 04:29

Re: How to get admin's information from users.ini
 
THXX Bugsy but can you say me how it's print Name and Flags... Why code doesn't print admin's password too ? :D

BaD CopY 05-28-2015 05:17

Re: How to get admin's information from users.ini
 
1. My server have more then 20 admins but motd print just 10 admins.
2. Can you add BG COLOR #000000 and font color #FFFFFF
3. Is possible to make motd who can change pages ? Exampe:

On one page code will print 15 admins... If server have more then 15 admins, then code will create more more motd (page)

http://www.dodaj.rs/f/11/jb/4IIizvcW/untitled.png

fysiks 05-28-2015 09:31

Re: How to get admin's information from users.ini
 
Quote:

Originally Posted by BaD CopY (Post 2301954)
THXX Bugsy but can you say me how it's print Name and Flags... Why code doesn't print admin's password too ? :D

  1. Why would you want to show passwords?
  2. Admins shouldn't have passwords and should be assigned by SteamID (Always).
  3. You can use my include to get a piece of information after the standard info in users.ini

Also, the MOTD cannot interact directly with a plugin that easily so making pages as you suggest is not really that easy.

BaD CopY 05-28-2015 15:34

Re: How to get admin's information from users.ini
 
@fyskis: Why would you want to show passwords?

I don't want to show password but I want to know how did he show only nick and flags...

And, can anyone add bgcolor to black and text to white in motd plzz..

Bugsy 05-28-2015 15:38

Re: How to get admin's information from users.ini
 
Look up how parse works. Where password is stored, I pass a temp/unused variable szTmp to read 1 character from it just to bypass it to get to flags.

BaD CopY 06-07-2015 16:40

Re: How to get admin's information from users.ini
 
Bugsy, sorry but again I don't understend how did you do it...

Can you help me about motd. I want if you can make and if is it possible, next page to motd (See my second photo, #5 comment)

Bugsy 06-07-2015 17:50

Re: How to get admin's information from users.ini
 
Quote:

Originally Posted by BaD CopY (Post 2305713)
Bugsy, sorry but again I don't understend how did you do it...

Can you help me about motd. I want if you can make and if is it possible, next page to motd (See my second photo, #5 comment)

Did you look up the function?

native parse(const text[], ... );

The function will parse the string in pieces of connected characters (can have no spaces or other possible delimiters) or characters enclosed in quotes (can have spaces or delimiter characters). It accepts a variable number of parameters which tells it how many pieces of data you want to parse. In this instance, we want 2 pieces, but there is a section in the middle that we do not want, which is the password field. A variable must be specified there as a placeholder in order to get to the next piece of data that is desired (flags).

<name|ip|steamid> <password> <access flags> <account flags>

szLine[] = "STEAM_0:0:12345" "" "abcdefghijklmnopqrstu" "ce"
parse( szLine , szAdminArray[ iAdminIndex ][ 0 ] , iMaxChars , szTmp , 1 , szAdminArray[ iAdminIndex ][ 1 ] , iMaxChars );


All times are GMT -4. The time now is 20:05.

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