Chatlog -
Snipa - 14.03.2011
pawn Код:
public OnPlayerText(playerid, text[])
{
//Chatlog
new chat[128],file[128],string[200],chater[128],hour,minute,second,year, month, day;
GetPlayerName(playerid,chater,sizeof(chater));
gettime(hour,minute,second);
getdate(year,month,day);
format(chat,sizeof(chat),"[T: %d:%d:%d D: %d %d %d] : ( %s ): %s",hour,minute,second, month, day, year,chater,text);
format(file,sizeof(file),"Logs/ChatLog.txt");
new INI:chatlog = INI_Open(file);
INI_WriteString(chatlog,"",string);
INI_Close(chatlog);
return 1;
}
It doesnt work.
I'm obviously doing something wrong, but cant find out what..
Re: Chatlog -
Jochemd - 14.03.2011
Folder created? Why are you formatting the file in first place?
Re: Chatlog -
Snipa - 14.03.2011
Scriptfiles/Logs/ChatLog.txt
I am formatting where the ChatLog.txt is
Re: Chatlog -
Jochemd - 14.03.2011
Not needed. Btw, use the implented samp write system for it. This is something to write like "Skin=120". It won't work if you put nothing in the second parameter of INI_WriteString.
pawn Код:
public OnPlayerText(playerid, text[])
{
//Chatlog
new chat[128],file[128],string[200],chater[128],hour,minute,second,year, month, day;
GetPlayerName(playerid,chater,sizeof(chater));
gettime(hour,minute,second);
getdate(year,month,day);
format(chat,sizeof(chat),"\r\n[T: %d:%d:%d D: %d %d %d] : ( %s ): %s",hour,minute,second, month, day, year,chater,text);
new File:chatlog = fopen("Logs/ChatLog.txt",io_append);
fwrite(chatlog,string);
fclose(chatlog);
return 1;
}
Supposed to work.
Re: Chatlog -
Kwarde - 14.03.2011
Yes, that's supposed to work indeed.
I use this my own xD. However here are some function I made and you can use
pawn Код:
stock WriteInFile(const string[], const file[])
{
new File:_tmpfile = fopen(file, io_append);
fwrite(_tmpfile, string);
fclose(_tmpfile);
return 1;
}
stock AddLog(const string[], const logfile[])
{
new str[150], logstr[50],
day, month, year,
hour, minute, second
;
getdate(year, month, day);
gettime(hour, minute, second);
format(str, 150, "[%02d-%02d-%04d %02d:%02d:%02d] %s\r\n", day, month, year, hour, minute, second, string);
WriteInFile(str, logfile);
return 1;
}
To add a logfile:
AddLog(const string[], const logfile[]);
Example:
AddLog(string, "Logs/Chatlog.txt");
Here's a whole new example for the chatlog
pawn Код:
public OnPlayerText(playerid, text[])
{
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, 128, "%s: %s", pName, text[0]);
AddLog(str, "Logs/Chatlog.txt");
return 1;
}
AddLog does automatic add log date+time (dd/mm/yyyy hh:mm

s)