Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-25-2011 , 08:33   Read users.ini and list on motd. *Need Help*
Reply With Quote #1

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.
.Dare Devil. is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-25-2011 , 10:24   Re: Read users.ini and list on motd. *Need Help*
Reply With Quote #2

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.
__________________


Last edited by SonicSonedit; 04-25-2011 at 10:28. Reason: forgot "if (!is_user_connected(i))" check statement
SonicSonedit is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-25-2011 , 10:56   Re: Read users.ini and list on motd. *Need Help*
Reply With Quote #3

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....
.Dare Devil. is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-25-2011 , 11:07   Re: Read users.ini and list on motd. *Need Help*
Reply With Quote #4

.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.
__________________


Last edited by SonicSonedit; 04-25-2011 at 11:16.
SonicSonedit is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-25-2011 , 11:43   Re: Read users.ini and list on motd. *Need Help*
Reply With Quote #5

Quote:
Originally Posted by SonicSonedit View Post
.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!
.Dare Devil. 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 19:52.


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