View Single Post
Author Message
D4rkSiD3Rs
Senior Member
Join Date: Jan 2018
Location: Morocco
Old 10-09-2018 , 14:48   Modify a file using another file
Reply With Quote #1

Hello,

I made that plugin which gets the names from a file 'file1.ini' and check if they are on another file 'file2.ini', and if the second argument in the line which the name is found (on file2) is 0 then delete that line in the file1. But, it didn't work! Can someone see where is the problem?

PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("File Cleaner""1.0""~D4rkSiD3Rs~");
    
CleanFile();
}

public 
CleanFile()
{
    
/* File 1 */
    
new configdir[200];
    
get_configsdir(configdir199);

    
format(configdir199"%s/file1.ini"configdir);

    new 
line 0;
    new 
linetextlength 0;
    new 
linetext[512]

    new 
name[32], option[32];
    
/* ****** */


    /* File 2 */
    
new configdir2[200];
    
get_configsdir(configdir2199);

    
format(configdir2199"%s/file2.ini"configdir2);

    new 
line2 0;
    new 
linetextlength2 0;
    new 
linetext2[512]

    new 
name2[32];
    
/* ****** */


    
while(read_file(configdirline++, linetextcharsmax(linetext), linetextlength))
    {
        
parse(linetextnamecharsmax(name), optioncharsmax(option));

        while(
read_file(configdir2line2++, linetext2charsmax(linetext2), linetextlength2))
        {
            
parse(linetext2name2charsmax(name2));

            if( 
equali(name2name) && equali(option"0") )
            {
                
formatex(linetextcharsmax(linetext), "");
                
write_file(configdirlinetextline 1);
            }
        }
    }

__________________



Last edited by D4rkSiD3Rs; 10-13-2018 at 17:52.
D4rkSiD3Rs is offline