Help With My Chat Log -
Alec24 - 29.03.2009
The script logs the messages in the chat box but how do I add the time when the message was sent to it.
Thanks
pawn Код:
public OnPlayerText(playerid, text[])
{
new pname[24], File:ftw=fopen("ChatLog.txt", io_append);
GetPlayerName(playerid, pname, 24);
new string[30];
format(string, 30, "%s : %s\r\n", pname,text);
fwrite(ftw, string);
fclose(ftw);
return 1;
}
Re: Help With My Chat Log -
FUNExtreme - 29.03.2009
Use this
https://sampwiki.blast.hk/wiki/Gettime
Just reply here if you don't understand how to work with it.
Re: Help With My Chat Log -
Pyrokid - 29.03.2009
What's wrong with using server_log.txt that comes with SA-MP?
Re: Help With My Chat Log -
illay - 29.03.2009
AlecRae,
1. Create file "Server Floder/scriptfiles/Logs/Chatlog.txt"
2. Install complete chat log script (did not test):
pawn Код:
#include <a_samp>
//--Defines
#define ChatL "Logs/Chatlog.txt" //server floder/scriptfiles..
public OnPlayerText(playerid, text[]) //by illay
{
new name[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"%s: %s",name,text);
WriteLog(ChatL,string); //+ Time
return 1;
}
//--Functions
stock WriteLog(const file[],const text[]) //by Goldkiller
{
new
c[128],
time[2],
File:cFile=cFile=fopen(file, io_append);
if(!cFile) return 0;
gettime(time[0],time[1]);
format(c,sizeof(c),"[%02d:%02d] %s\r\n",time[0],time[1],text);
fwrite(cFile,c);
fclose(cFile);
return 1;
}
One line in Chatlog: [Time] playerid (name): Text
Re: Help With My Chat Log -
FUNExtreme - 29.03.2009
Quote:
Originally Posted by Pyrokid
What's wrong with using server_log.txt that comes with SA-MP?
|
His function will only save chat logg while server_log.txt saves: Kills, deaths, connects, disconnects, etc
Re: Help With My Chat Log -
illay - 29.03.2009
FUNExtreme,
Yes, organ root directory went chat words. (server_log.txt) + Player IP in Connect
Re: Help With My Chat Log -
FUNExtreme - 29.03.2009
Quote:
Originally Posted by illay
FUNExtreme,
Yes, organ root directory went chat words. (server_log.txt) + Player IP in Connect
|
I wont lie about it youknow.
Re: Help With My Chat Log -
Alec24 - 29.03.2009
I have managed to get it working with
pawn Код:
public OnPlayerText(playerid, text[])
{
new pname[24], File:ftw=fopen("ChatLog.txt", io_append);
new Hour, Minute, Second;
new string[30];
GetPlayerName(playerid, pname, 24);
gettime(Hour, Minute, Second);
format(string, 30, "[%02d:%02d:%02d] %s : %s\r\n" ,Hour,Minute,Second,pname,text);
fwrite(ftw, string);
fclose(ftw);
return 1;
}
Its quite different from
Quote:
Originally Posted by illay
AlecRae,
1. Create file "Server Floder/scriptfiles/Logs/Chatlog.txt"
2. Install complete chat log script (did not test):
pawn Код:
#include <a_samp>
//--Defines #define ChatL "Logs/Chatlog.txt" //server floder/scriptfiles..
public OnPlayerText(playerid, text[]) //by illay { new name[MAX_PLAYER_NAME]; new string[256]; GetPlayerName(playerid,name,sizeof(name)); format(string,sizeof(string),"%s: %s",name,text); WriteLog(ChatL,string); return 1; }
//--Functions stock WriteLog(const file[],const text[]) //by Goldkiller { new c[128], time[2], File:cFile=cFile=fopen(file, io_append); if(!cFile) return 0; gettime(time[0],time[1]); format(c,sizeof(c),"[%02d:%02d] %s\r\n",time[0],time[1],text); fwrite(cFile,c); fclose(cFile); return 1; }
|
But is it still ok?
Re: Help With My Chat Log -
FUNExtreme - 29.03.2009
Yes it is ok. The other one just uses an outside function wich is usefull if you use it alot.
Yours will work just well.
Re: Help With My Chat Log -
illay - 29.03.2009
AlecRae,
ok