SA-MP Forums Archive
My admin log - 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: My admin log (/showthread.php?tid=626297)



My admin log - Ahmed21 - 13.01.2017

Hello, I've made simple & basic admin log. It creates a file and writes in it.

Problem:
It is supposed to write in the file and then make a new line, but it's writing everything in same line. I mean, there is no different if I keep that \n or I remove it.

Script:
PHP Code:
forward adminLog(logstring[]);
public 
adminLog(logstring[])
{
    new 
File:hFile;
    new 
entry[256];
    
format(entrysizeof(entry), "%s\n",logstring);
    
hFile fopen("Logs/admin_log.log"io_append);
    
fwrite(hFileentry);
    
fclose(hFile);




Re: My admin log - Lordzy - 13.01.2017

Quote:
Originally Posted by SAMPWiki
A little explanation about the escape codes; the "\n" will begin a new line, and the \r makes sure it starts at the beginning, not somewhere in the middle of a line, so it wont end up like
Try adding "\r" before "\n". But still your code is supposed to generate a new line, which may not write from beginning. I'm also suggesting you to check if the file handle is valid before using fwrite and fclose.


Re: My admin log - Ahmed21 - 13.01.2017

Quote:
Originally Posted by Lordzy
View Post
Try adding "\r" before "\n". But still your code is supposed to generate a new line, which may not write from beginning. I'm also suggesting you to check if the file handle is valid before using fwrite and fclose.
Amazing, thank you, it worked! +REP'd