File lines are overwriting - 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)
+--- Thread: File lines are overwriting (
/showthread.php?tid=321968)
File lines are overwriting -
milanosie - 29.02.2012
So, I am making this log but it only writes on the first line, its overwriting the previous line over and over again, what is wrong?
pawn Код:
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
new File:cmdlog = fopen("realityrp/logs/commands.txt", io_write);
fwrite(cmdlog, text);
fwrite(cmdlog, "\r\n");
fclose(cmdlog);
return 1;
}
Re: File lines are overwriting -
thimo - 29.02.2012
I had this problem before too... I fixed it with using a timer wich DOESNT repeat :P
Re: File lines are overwriting -
Stigg - 29.02.2012
Quote:
Originally Posted by milanosie
So, I am making this log but it only writes on the first line, its overwriting the previous line over and over again, what is wrong?
pawn Код:
forward writecmdlog(text[]); stock writecmdlog(text[]) { new File:cmdlog = fopen("realityrp/logs/commands.txt", io_write); fwrite(cmdlog, text); fwrite(cmdlog, "\r\n"); fclose(cmdlog); return 1; }
|
Try changing 'io_write' to 'io_append'
Re: File lines are overwriting - T0pAz - 29.02.2012
Use
io_append instead of
io_write.
Re: File lines are overwriting -
milanosie - 29.02.2012
Thanks, im completly new to Fwrite etc, always used ini stuff
Re: File lines are overwriting -
thimo - 29.02.2012
This happend to me using Mysql so
doesnt matter what system i guess
Re: File lines are overwriting -
iPLEOMAX - 29.02.2012
For safety..
pawn Код:
forward writecmdlog(text[]);
stock writecmdlog(text[])
{
new File:LOG;
if(!fexist("realityrp/logs/commands.txt"))
LOG = fopen("realityrp/logs/commands.txt", io_write);
else
LOG = fopen("realityrp/logs/commands.txt", io_append);
fwrite(LOG, text);
fwrite(LOG, "\r\n");
fclose(LOG);
return 1;
}