File doesn't save (.cfg)
#1

This is my code:

Код:
enum PhoneInf
{
	nNumber
};
new PhoneInfo[200][PhoneInf];

public OnFilterScriptExit()
{
	SavePhones();
	return 1;
}

stock SavePhones()
{
	new idx = 1, File:file;
	new string[256];
	while(idx < 200)
	{
	    format(string, sizeof(string), "%d\r\n",PhoneInfo[idx][nNumber]);
	    if(idx == 1)
	    {
	        file = fopen("phones.cfg", io_write);
	    }
	    else
	    {
	    	file = fopen("phones.cfg", io_append);
	    }
		fwrite(file, string);
		fclose(file);
		idx++;
	}
}
It all works great while the server is online. I even went to check if SavePhones(); works correctly by adding it in the middle of the script and the .cfg file looked just as I want.

But the main problem and the only problem is that all the data after the filterscript/server gets reset is set to 0. And all I get in the .cfg after the reloading of the filterscript is "0" and more "0".

The data somehow gets dumped after the filterscript is reloaded, like it just disapears.
Reply
#2

Add:
PHP код:
printf(string); 
while writing.

But i would like to suggest you, creating one string with
Код:
strcat
and executing fwrite once....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)