AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Read users.ini and list on motd. *Need Help* (https://forums.alliedmods.net/showthread.php?t=155674)

.Dare Devil. 04-25-2011 08:33

Read users.ini and list on motd. *Need Help*
 
Hi.

Like a title say i want a create such plugin like admin/vip list on motd.
It is first time when i try to load .ini file :)

I was try to make this.
Lets look my code now :)
PHP Code:

 
#include <amxmodx>
#include <amxmisc>
#define PLUGIN  "Users list on motd"
#define VERSION "1.0"
#define AUTHOR  "Dare-Devil - This man need somehelp :)"
public plugin_precache()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 static 
configsdir[32]
 
get_configsdir(configsdir31)
 static 
file[64]
 
formatex(file63"%s/users.ini"configsdir)
 new 
line 0length 0
 
static users[64], flags[32]
 while(
read_file(fileline++, text127length)) 
 {
  if((
text[0] == ';') || !length)
   continue
 
// And what is a next ( ? )
}
public 
plugin_init()
{
 
register_clcmd("say /adminlist""show_admin_or_vip_list")
}
public 
show_admin_or_vip_list(id)
{
 
format_motd_admin(g_sBuffer)
 
show_motd(idg_sBuffer"Admin or Vip List")
 
 return 
PLUGIN_CONTINUE
}
format_motd_admin(sBuffer[MAX_BUFFER_LENGTH 1])
{
 new 
izList[8], izBody[8]
 new 
iLen 0
 
new ladminname[16], ladminflag[16],
 
format(ladminnames15"%L"LANG_SERVER"LANG_ADMINNAME")
 
format(lladminflag15"%L"LANG_SERVER"LANG_ADMINFLAG")
 
// And somehelp here please :) 

Like you see i dont know now how to continue, I would be very grateful if someone help me.

SonicSonedit 04-25-2011 10:24

Re: Read users.ini and list on motd. *Need Help*
 
something like this should do:
PHP Code:

#include <amxmodx>

#define PLUGIN  "Users list on motd"
#define VERSION "1.0"
#define AUTHOR  "Sonedit test 8"

new flag[]="abcdefghijklmnopqrstu!!!yz"

new g_maxplayers

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("adminlist""clcmd_adminlist")
    
register_clcmd("say adminlist""clcmd_adminlist")
    
register_clcmd("say /adminlist""clcmd_adminlist")
    
    
g_maxplayers get_maxplayers()
}

public 
clcmd_adminlist(id)
{
    static 
ilstrtemp[2048], strtemp2[32]
    
    
strtemp=""
    
    
for (i=0;i<=g_maxplayers;i++)
    {
        if (!
is_user_connected(i))
            continue

        
get_user_name(istrtemp2charsmax(strtemp2))
        
add(strtempcharsmax(strtemp), strtemp2charsmax(strtemp2))
        
add(strtempcharsmax(strtemp), " flags: "strlen(" flags: "))
        
        for (
l=0;l<26;l++)
            if (
get_user_flags(i,0)&(1<<l))
                
add(strtempcharsmax(strtemp), flag[l], 1)
    }
    
    
add(strtempcharsmax(strtemp), "^n"1)

    
show_motd(idstrtemp"Admin or Vip List")
    
    return 
PLUGIN_HANDLED


Not tested.

To understand what " if (get_user_flags(i,0)&(1<<l))" does, check amxmodx.inc for info, everything will be crystal clear for you, if you will do that.

.Dare Devil. 04-25-2011 10:56

Re: Read users.ini and list on motd. *Need Help*
 
You dont undestand.
I need to read users.ini and place all acc in a motd , something like this :

Quote:


Admin Name Flags

Dare-Devil abcdefght....
Someone abcdeght....


SonicSonedit 04-25-2011 11:07

Re: Read users.ini and list on motd. *Need Help*
 
.Dare Devil.
so, users.ini, not users who currently playing? In that case. try this:
PHP Code:

public clcmd_adminlist(id)
{
    static 
lengthlstrtemp[2048], strtemp2[128], file[64]
    
    
get_localinfo("amxx_configsdir",strtemp2charsmax(strtemp2))
    
format(filecharsmax(file), "%s/users.ini"strtemp2)
        
strtemp=""
    
     
while((l=read_file(filelstrtemp2charsmax(strtemp2), length))) 
     {
        if(
strtemp2[0]==';'||!length)
            continue
            
        
add(strtempcharsmax(strtemp), strtemp2charsmax(strtemp2))
        
add(strtempcharsmax(strtemp), "^n"1)
    }
    

    
show_motd(idstrtemp"Admin or Vip List")
    
    return 
PLUGIN_HANDLED


You can get user name, ip/steamid/password and flags by parsing strtemp2 with " symbol.

.Dare Devil. 04-25-2011 11:43

Re: Read users.ini and list on motd. *Need Help*
 
Quote:

Originally Posted by SonicSonedit (Post 1457473)
.Dare Devil.
so, users.ini, not users who currently playing? In that case. try this:
PHP Code:

public clcmd_adminlist(id)
{
    static 
lengthlstrtemp[2048], strtemp2[128], file[64]
 
    
get_localinfo("amxx_configsdir",strtemp2charsmax(strtemp2))
    
format(filecharsmax(file), "%s/users.ini"strtemp2)
        
strtemp=""
 
     
while((l=read_file(filelstrtemp2charsmax(strtemp2), length))) 
     {
        if(
strtemp2[0]==';'||!length)
            continue
 
        
add(strtempcharsmax(strtemp), strtemp2charsmax(strtemp2))
        
add(strtempcharsmax(strtemp), "^n"1)
    }
 
 
    
show_motd(idstrtemp"Admin or Vip List")
 
    return 
PLUGIN_HANDLED


You can get user name, ip/steamid/password and flags by parsing strtemp2 with " symbol.

Nice that help me a lot! :)


All times are GMT -4. The time now is 19:52.

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