SA-MP Forums Archive
Small help regarding logs - 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: Small help regarding logs (/showthread.php?tid=435683)



Small help regarding logs - Squirrel - 08.05.2013

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.


Re : Small help regarding logs - DaTa[X] - 08.05.2013

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



Re: Small help regarding logs - Chenko - 08.05.2013

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


AW: Small help regarding logs - Squirrel - 08.05.2013

Thanks a bunch guys!!!!