My admin log
#1

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);

Reply
#2

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.
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)