27.06.2011, 16:54
(
Последний раз редактировалось System64; 12.09.2011 в 13:02.
)
Hi all! This is my first tutorial on this forum and I'll show you how to make a chat log for your server
It's very simple, it have few steps!
2. Copy this somewhere on the bottom of your script!
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);
fwrite(lFile, logData);
fclose(lFile);
return 1;
}
pawn Код:
File:lFile = fopen("Logs/Chat.txt", io_append)
pawn Код:
logData[178]
pawn Код:
fyear, fmonth, fday, fhour, fminute, fsecond
pawn Код:
getdate(fyear, fmonth, fday);
gettime(fhour, fminute, fsecond);
pawn Код:
format(logData, sizeof(logData),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", fday, fmonth, fyear, fhour, fminute, fsecond, GetName(playerid), text);
pawn Код:
logData
pawn Код:
fday, fmonth, fyear, fhour, fminute, fsecond
pawn Код:
GetName(playerid)
pawn Код:
text
pawn Код:
fwrite(lFile, logData);
pawn Код:
fclose(lFile);
One more function we need to add on the bottom of your script:
pawn Код:
stock GetName(playerid)
{
new
pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
return pName;
}
pawn Код:
ChatLog(playerid, text);
pawn Код:
[17/06/2011 09:20:15] System32: test
Tutorial by System32
Script by Paradox
If I do something wrong or type something wrong please say!