Raised This Month: $ Target: $400
 0% 

[HELP] Creatting and editting file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 11-11-2009 , 22:08   [HELP] Creatting and editting file
Reply With Quote #1

Hi! I'm here again u.u.
In this case i have to create and writting or delete a external file..
I do this :
PHP Code:
new fileban[256]
stock bool:cont_exists(file[],name[])
{
    new 
file_pointer fopen(file"rt")
    
    new 
Buffer[256]
    
    while (!
feof(file_pointer))
    {
        
fgets(file_pointerBuffer31)
        
        
        if(
containi(Buffername) != -1)
        {
            
fclose(file_pointer)
            return 
true
        
}
    }
    return 
false
}
.....
public 
plugin_init() {
.....
    
check_file()
    
}
.....
        new 
file fopen(fileban"wt")
        
fprintf(file"^n%s"szTargetName//Here i add this line to the file
        
fclose(file)
.....
if(
file)
    {
        new 
Buffer[128]
        new 
counter
        
        
while(!feof(file))
        {
            
fgets(fileBuffer128)
        
            
parse(BufferBuffersizeof Buffer -1)
            
            if(
equal(Buffername))
            {    

            
write_file(fileban,"",counter// Here i replace the line "counter" by ""

            
            
}
            
counter++
        }

    
        
fclose(file)
    }
return 
PLUGIN_HANDLED
}
public 
check_file()
{
    new 
datadir[64]
    
get_datadir(datadir63)
    
    
format(filebansizeof fileban 1"%s/asd.ini"datadir)
    
    new 
file_pointer fopen(fileban"at+")
    
    if(!
file_pointer)
    {
        
write_file(fileban,"//File created",0)
    }
    
    if(
file_pointer)
    {
        
server_print("The file %s was created"fileban)
        
write_file(fileban""0)
    } 
    
fclose(file_pointer)

This is the part of the code that have connection with the external file.
The file is never created and can't edit anything or read it because it doesn't exist.

Any help?

My greets and thanks! & sorry for my english

Last edited by Mxnn; 11-11-2009 at 22:11.
Mxnn 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 13:39.


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