Raised This Month: $ Target: $400
 0% 

Write in users file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mats
Senior Member
Join Date: Jan 2005
Old 09-04-2008 , 10:07   Write in users file
Reply With Quote #1

I have
Code:
		format(strLine, 255, "%s ^"^" ^"%s^" ^"ce^" ;%s",Admins[i][USERID],Admins[i][USERFLAGS], Admins[i][USERNAME]) 
		write_file(strUsersFileNew,strLine,-1)
That add a line to my users.ini it was working very good but now not anymore (i think because there are more people now that will be added)
It now shows in the uses.ini

STEAM_0:1:111111111 "" "bs" "ce" ;name

The "" are on the wrong place, do someone see a error in this line?
__________________
mats is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 09-04-2008 , 10:09   Re: Write in users file
Reply With Quote #2

where do u want the ""?
Give us a line of what u do want
E.g. "STEAM:0:0000" "" "abcdefg" "ce" ;Stewie!

P.s. mats, its me: Stewie ;)
__________________
minimiller is offline
Send a message via MSN to minimiller
mats
Senior Member
Join Date: Jan 2005
Old 09-04-2008 , 11:11   Re: Write in users file
Reply With Quote #3

It is now STEAM_0:1:111111111 "" "bs" "ce" ;name
but it should be
"STEAM_0:1:111111111" "bs" "ce" ;name
__________________
mats is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 09-04-2008 , 11:23   Re: Write in users file
Reply With Quote #4

Use this

Quote:
format(strLine, 255, "^"%s^" ^"%s^" ^"ce^" ;%s",Admins[i][USERID],Admins[i][USERFLAGS], Admins[i][USERNAME])
write_file(strUsersFileNew,strLine,-1)
__________________
minimiller is offline
Send a message via MSN to minimiller
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-04-2008 , 11:27   Re: Write in users file
Reply With Quote #5

This is what I use in one of my plugins to write a new admin. It will verify the admin does not already exist before adding. Whatever you pass as comment will show up after the semi-colon.

PHP Code:
public cmd_AddAdmin(auth[], accessflags[], password[], flags[], comment[])
{
    
/*This has been modified from the original amxmodx version to allow
    for input of the comment line. This allows a comment to be specified
    instead of only being supplied if the added admin is online at
    the time of being added*/
    
    // Make sure that the users.ini file exists.
    
new configsDir[64];
    
get_configsdir(configsDir63);
    
format(configsDir63"%s/users.ini"configsDir);

    if (!
file_exists(configsDir))
    {
        
console_print(0"[%s] File ^"%s^" doesn't exist."PLUGINconfigsDir);
        return;
    }

    
// Make sure steamid isn't already in file.
    
new line 0textline[256], len;
    const 
SIZE 63;
    new 
line_steamid[SIZE 1], line_password[SIZE 1], line_accessflags[SIZE 1], line_flags[SIZE 1], parsedParams;
    
    
// <name|ip|steamid> <password> <access flags> <account flags>
    
while ((line read_file(configsDirlinetextline255len)))
    {
        if (
len == || equal(textline";"1))
            continue; 
// comment line

        
parsedParams parse(textlineline_steamidSIZEline_passwordSIZEline_accessflagsSIZEline_flagsSIZE);
        
        if (
parsedParams != 4)
            continue;    
// Send warning/error?
        
        
if ( (containi(line_flagsflags) != -1) && (equal(line_steamidauth)) )
        {
            
console_print(0"[%s] %s already exists!"PLUGINauth);
            return;
        }
    }

    
// If we came here, steamid doesn't exist in users.ini. Add it.
    
new linetoadd[512];
    
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s"authpasswordaccessflagsflagscomment);

    if (!
write_file(configsDirlinetoadd))
        
log_amx("Failed writing admin [%s:%s]"authcomment);

__________________
Bugsy is offline
mats
Senior Member
Join Date: Jan 2005
Old 09-04-2008 , 11:52   Re: Write in users file
Reply With Quote #6

Quote:
Originally Posted by minimiller View Post
Use this
Thx this worked ;)

Quote:
Originally Posted by Bugsy View Post
This is what I use in one of my plugins to write a new admin. It will verify the admin does not already exist before adding. Whatever you pass as comment will show up after the semi-colon.

PHP Code:
public cmd_AddAdmin(auth[], accessflags[], password[], flags[], comment[])
{
    
/*This has been modified from the original amxmodx version to allow
    for input of the comment line. This allows a comment to be specified
    instead of only being supplied if the added admin is online at
    the time of being added*/
    
    // Make sure that the users.ini file exists.
    
new configsDir[64];
    
get_configsdir(configsDir63);
    
format(configsDir63"%s/users.ini"configsDir);

    if (!
file_exists(configsDir))
    {
        
console_print(0"[%s] File ^"%s^" doesn't exist."PLUGINconfigsDir);
        return;
    }

    
// Make sure steamid isn't already in file.
    
new line 0textline[256], len;
    const 
SIZE 63;
    new 
line_steamid[SIZE 1], line_password[SIZE 1], line_accessflags[SIZE 1], line_flags[SIZE 1], parsedParams;
    
    
// <name|ip|steamid> <password> <access flags> <account flags>
    
while ((line read_file(configsDirlinetextline255len)))
    {
        if (
len == || equal(textline";"1))
            continue; 
// comment line

        
parsedParams parse(textlineline_steamidSIZEline_passwordSIZEline_accessflagsSIZEline_flagsSIZE);
        
        if (
parsedParams != 4)
            continue;    
// Send warning/error?
        
        
if ( (containi(line_flagsflags) != -1) && (equal(line_steamidauth)) )
        {
            
console_print(0"[%s] %s already exists!"PLUGINauth);
            return;
        }
    }

    
// If we came here, steamid doesn't exist in users.ini. Add it.
    
new linetoadd[512];
    
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s"authpasswordaccessflagsflagscomment);

    if (!
write_file(configsDirlinetoadd))
        
log_amx("Failed writing admin [%s:%s]"authcomment);

I added the users on a my phpbb forum and not on the server, users are loaded every mapchange
__________________
mats 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 03:17.


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