SA-MP Forums Archive
fwrite isnґt working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: fwrite isnґt working (/showthread.php?tid=72682)



fwrite isnґt working - NtCat - 10.04.2009

Hi. I made this command:
Код:
dcmd_8889(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
		new year, month, day, hour, minute, second;
		getdate(year, month, day);
		gettime(hour, minute, second);
		new string[256], fname[11];
		format(string, sizeof(string), "\n%d/%d/%d %d:%d:%d - %s: %s", year, month, day, hour, minute, second, Nick(playerid), params);
		format(fname, sizeof(fname), "FK/8889.txt");
		new File:file8889 = fopen(fname, io_write);
		fwrite(file8889, string);
		fclose(file8889);
	}
    return 1;
}
And I donґt get any errors, file 8889.txt is created, but nothing is written in it. What is that caused by? Thanks.

P.S. I tested it on Windows localhost, but I donґt think itґs matter.


Re: fwrite isnґt working - Nubotron - 10.04.2009

A better title: "My code isn't working", as fwrite work perfectly.

fname is not big enough for what you fill in it..it need one more cell, for the null character at the end, also you do not need format as you do not format anything, just do #define fname "FK/8889.txt", or new fname[] = "FK/8889.txt";