Small help regarding logs
#1

Hello guys, well I got 1 problem and 1 question.

-Problem: After you use for example some command it will write it how it should but it always writes everything in the same line... It goes like this
Код:
<A>Boss is now on duty as administrator!<A>Boss is now on duty as administrator!
Код:
public AdminLog(string[])
{
    new entry[128];
    format(entry, sizeof(entry), "%s\n",string);
    new File:hFile;
    hFile = fopen("/LOGS/AdminLog.log", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
-Question: How can I implement that it saves the time too? Time when command was used.
Reply
#2

you can use this function gettime or getdate and store them in vars

pawn Код:
public AdminLog(string[])
{
    new entry[128];
    new day,month,year;
    getdate(day,month,year);
    format(entry, sizeof(entry), "[%d/%d/%d]  %s\r\n ",day,month,year,string);
    new File:hFile;
    hFile = fopen("/LOGS/AdminLog.log", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}
Reply
#3

Use \r\n at the end not just \n and it should start it on a new line.
Reply
#4

Thanks a bunch guys!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)