open.mp forum
[Pawn] timestamp include - i need help - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] timestamp include - i need help (/showthread.php?tid=2732)



timestamp include - i need help - justcroatiansamper - 2024-05-10

Hello, how would it be best to implement timestamp include in this situation? 


Code:
stock CreateLog(FileName[], string[])[/color]
{

    new logstring[256];

    new hour, minute, second, day, month, year;

    gettime(hour, minute, second);

    getdate(day, month, year);

    format(logstring, 256, "[%d.%d.%d - %d:%d:%d] %s\r\n", hour, minute, second, day, month, year, string);

    new File:hFile;

    hFile = fopen(FileName, io_append);

    fwrite(hFile, logstring);

    fclose(hFile);

    return 1;
[color=#000000]}



Link of timestamp:
https://github.com/Agneese-Saini/SA-MP/blob/master/pawno/include/timestamp.inc


Thanks :)


RE: timestamp include - i need help - justcroatiansamper - 2024-05-12

I did it in this way

Code:
stock CreateLog(FileName[], string[])
{
    new logstring[256];
    format(logstring, 256, FormatTimestamp(Timestamp(), "[%d/%m/%y-%H:%M]: %s\r\n"),string);
    new File:hFile;
    hFile = fopen(FileName, io_append);
    fwrite(hFile, logstring);
    fclose(hFile);
    return 1;
}


Thread can be locked