#include <file>
forward ChatLog(chattext[]);
public ChatLog(chattext[]) { new entry[300],day,month,year,second,hour,minute, File:hFile; gettime(hour,minute,second); getdate(year,month,day); format(entry,sizeof(entry),"[%02d/%02d/%04d %02d:%02d:%02d] %s\n",day, month, year, hour, minute, second, chattext); hFile = fopen("Logs/chat.txt",io_append); fwrite(hFile,entry); fclose(hFile); }
public OnPlayerText(playerid, text[]) { new textv2[128], pname[25], Float:x, Float:y, Float:z, chattext[300]; GetPlayerName(playerid,pname,24); GetPlayerPos(playerid,x,y,z); format(textv2,sizeof(textv2), "%s says: %s", pname, text); for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerInRangeOfPoint(i,100.0,x,y,z)) { SendClientMessage(i,COL_WHITE,textv2); format(chattext,sizeof(chattext),"%s",textv2); ChatLog(chattext); } } return 0; }
[23:14:57] Incoming connection: 127.0.0.1:54308 [23:14:57] [join] BlackThief has joined the server (0:127.0.0.1) [23:15:03] [debug] Server crashed while executing test0.1.amx [23:15:03] [debug] AMX backtrace: [23:15:03] [debug] #0 native fwrite () [004056e0] from samp-server.exe [23:15:03] [debug] #1 000096d4 in public ChatLog (0x0002f770) from test0.1.amx [23:15:03] [debug] #2 0000c34c in public OnPlayerText (0x00000000, 0x0002bea8) from test0.1.amx [23:15:03] [debug] Native backtrace: [23:15:03] [debug] #0 77ed3632 in ?? () from C:\Windows\SYSTEM32\ntdll.dll [23:15:03] [debug] #1 00493990 in ?? () from samp-server.exe [23:15:03] [debug] #2 0040531e in ?? () from samp-server.exe
hFile = fopen("Logs/chat.txt",io_append);
fwrite(hFile,entry);
fclose(hFile);
hFile = fopen("Logs/chat.txt",io_append);
if (hFile)
{
fwrite(hFile,entry);
fclose(hFile);
}
Replace:
I already mentioned that it can crash the server in that thread. It's good to read the comments before using something! |