if(!fexist("updates.cfg"))
{
new File:handle = fopen("updates.cfg", io_readwrite);
fclose(handle);
}
else
{
new File:file = fopen("updates.cfg", io_readwrite), idx = 1, string[128];
while(fread(file, string))
{
if(strfind(string, "type:2") != -1)
{
fdeleteline("updates.cfg", idx);
strdel(string, strlen(string) - 8, strlen(string));
strins(string, "type:0", strlen(string), sizeof(string));
fwrite(file, string);
}
idx++;
}
fclose(file);
}
you need to close the file before using fdeleteline otherwise it can't open the file as it is already opened
fdeleteline is always a bad option, implement the code by yourself than you can write new lines at the deleted position (or create a freplace function) Also if you use io_readwrite, you need to work with fseek and remeber that fwrite can overwrite existing content of the file If you need an example / solution for io_readwrite I could show you |
if(!fexist("updates.cfg"))
{
new File:handle = fopen("updates.cfg", io_readwrite);
fclose(handle);
}
else
{
new File:file = fopen("updates.cfg", io_readwrite), idx = 1, string[128];
while(fread(file, string))
{
if(strfind(string, "type:2") != -1)
{
fdeleteline("updates.cfg", idx);
strdel(string, strlen(string) - 8, strlen(string));
strins(string, "type:0", strlen(string), sizeof(string));
fwrite(file, string);
fclose(file);
}
idx++;
}
}
if(!fexist("updates.cfg"))
{
new File:handle = fopen("updates.cfg", io_readwrite);
fclose(handle);
}
else
{
new File:file = fopen("updates.cfg", io_readwrite), string[128];
while(fread(file, string))
{
if(strfind(string, "type:2") != -1)
{
string[5] = '1'; // mark as implemented
fwrite(file, string);
}
}
fclose(file);
}