Server Chatlogging Help
#2

Writing to a file or closing a file without checking if the file handle (whether it opened successfully) is valid can crash the server.
pawn Код:
stock ChatLog(playerid, text[])
{
    new
        File:lFile = fopen("Logs/Chat.txt", io_append),
        logData[178],
        fyear, fmonth, fday,
        fhour, fminute, fsecond;
   
    getdate(fyear, fmonth, fday);
    gettime(fhour, fminute, fsecond);
   
    format(logData, sizeof(logData),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", fday, fmonth, fyear, fhour, fminute, fsecond, GetName(playerid), text);
    if (lFile)
    {
        fwrite(lFile, logData);
        fclose(lFile);
    }
    return 1;
}
Another thing is the folders. Make sure you've created the correct folder (Logs) in scriptfiles because fwrite will crash the server.
Reply


Messages In This Thread
Server Chatlogging Help - by PrivatioBoni - 04.02.2014, 18:06
Re: Server Chatlogging Help - by Konstantinos - 04.02.2014, 18:09
Re: Server Chatlogging Help - by PrivatioBoni - 04.02.2014, 18:17
Re: Server Chatlogging Help - by Konstantinos - 04.02.2014, 18:20
Re: Server Chatlogging Help - by PrivatioBoni - 04.02.2014, 18:26

Forum Jump:


Users browsing this thread: 1 Guest(s)