AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Write in users file (https://forums.alliedmods.net/showthread.php?t=77052)

mats 09-04-2008 10:07

Write in users file
 
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?

minimiller 09-04-2008 10:09

Re: Write in users file
 
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 ;)

mats 09-04-2008 11:11

Re: Write in users file
 
It is now STEAM_0:1:111111111 "" "bs" "ce" ;name
but it should be
"STEAM_0:1:111111111" "bs" "ce" ;name

minimiller 09-04-2008 11:23

Re: Write in users file
 
Use this

Quote:

format(strLine, 255, "^"%s^" ^"%s^" ^"ce^" ;%s",Admins[i][USERID],Admins[i][USERFLAGS], Admins[i][USERNAME])
write_file(strUsersFileNew,strLine,-1)

Bugsy 09-04-2008 11:27

Re: Write in users file
 
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);



mats 09-04-2008 11:52

Re: Write in users file
 
Quote:

Originally Posted by minimiller (Post 681101)
Use this

Thx this worked ;)

Quote:

Originally Posted by Bugsy (Post 681104)
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


All times are GMT -4. The time now is 03:17.

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