Logging command
#1

Hello I've started to log what players are doing such as commands, but I've got a problem, then way it logs, it logs it all on one line, but I wanted it so it would be like.
Quote:

Player has joined the server
Player has joined the server

but at the moment it logs like
Quote:

Player has joined the server Player has joined the server

my logging code is


pawn Код:
format(str2, sizeof str2, "[COMMAND][%02d/%02d/%04d %02d:%02d:%02d]: %s(%d): has used /stats", lyear, lmonth, lday, lhour, lminute, lsecond, name, ID);
AllLogs(str2);
pawn Код:
stock AllLogs(event[])
{
  new File:log = fopen("Core/Logs/AllLogs.txt", io_append);
  fwrite(log, event);
  fwrite(log, "\n");
  fclose(log);
}
If you know what's wrong it would be great if you could tell me, Also I have to know what does this mean on the Stock
Quote:

fwrite(log, event);

is that the bit I am logging?
Reply
#2

try to log by printing in the console.i think its easier than makeing a new file.
Like This :
Код:
public OnPlayerConnect(playerid)
{
	new pName[24];
	GetPlayerName(playerid,pName,24);
	printf("Player %s has joined to server",pName);

	return 1;
};
it will be logged in server_log.txt and the time will be write on each line too
Reply
#3

I do not want to do this, I already know of this way, thanks for trying to help
Reply
#4

Event is the input of the string. In your case, the string is what your 'logging'.

I suggest trying this;
pawn Код:
format(str2, sizeof str2, "[COMMAND][%02d/%02d/%04d %02d:%02d:%02d]: %s(%d): has used /stats\n", lyear, lmonth, lday, lhour, lminute, lsecond, name, ID);
AllLogs(str2);
or you could try this as Ryz stated below;
pawn Код:
stock AllLogs(event[])
{
  new File:log = fopen("Core/Logs/AllLogs.txt", io_append);
  fwrite(log, "\n");// Remove this if the code shown above works.
  fwrite(log, event);
  fclose(log);
}
For more information regarding fWrite, please refer to this resource.
- https://sampwiki.blast.hk/wiki/Fwrite
Reply
#5

removed

EDIT: GOT ANSWERED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)