Raised This Month: $51 Target: $400
 12% 

Solved Modify a file using another file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 07:08.


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