04.02.2014, 18:09
Writing to a file or closing a file without checking if the file handle (whether it opened successfully) is valid can crash the server.
Another thing is the folders. Make sure you've created the correct folder (Logs) in scriptfiles because fwrite will 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;
}