SA-MP Forums Archive
Command Log - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command Log (/showthread.php?tid=231085)



Command Log - SanAndreasVille - 24.02.2011

Hello how can i make a Log file from all Commands from the players ?

how can I create a log file from the server command which a player enters?


Re: Command Log - maramizo - 24.02.2011

Use Y_ini.


Re: Command Log - dice7 - 24.02.2011

OnPlayerCommandText
printf("Player (id=%d) typed the command=%s", playerid, cmdtext);

And it will save it to your server log file


Re: Command Log - Hiddos - 24.02.2011

What the person above me said, OR if you want commands in specific files:
pawn Код:
stock LogCommand(event[])
{
  new File:log = fopen("command_log.txt", io_append);
  fwrite(log, event);
  fwrite(log, "\n");
  fclose(log);
}
Should work by 'LogCommand();', however I did not test the code.

Example usage:

pawn Код:
COMMAND:heal(playerid, params[])
{
  new target;
  if(sscanf(params, "u", target)) return SendClientMessage(playerid, 0x00ff0f00, "Usage: /heal [playerid/name]");
  else if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0x00ff0f00, "Invalid player!");
  SetPlayerHealth(target, 100);
  new gName[MAX_PLAYER_NAME], string[128];
  GetPlayerName(target, gName, MAX_PLAYER_NAME);
  GetPlayerName(playerid, string, MAX_PLAYER_NAME);
  format(string, sizeof string, "[HEAL] %s has healed %s", string, gName); //Important: Formats the string to log
  CommandLog(string); //Log the string
  return 1;
}
Hope that kind of explained it to you.


Re: Command Log - SanAndreasVille - 24.02.2011

thanks,

I would like when a player join the server it in the log file so:

Player (ID:5) joined the server

i want the ID in the Log so can i see in the log how many Players played today on tzhe server


Re: Command Log - pawn_ - 24.02.2011

You don't need to create necessary files in your folder, that means more disk-space, however, you may try printing to server_log.txt in your server directory.

On top:

pawn Код:
new PlayerCount = 0;
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new playername[24];
    GetPlayerName(playerid, playername, 24);
    printf("[cmd] %s(%d): %s", playername, playerid, cmdtext);
    return 0;
}
And for connecting:

pawn Код:
public OnPlayerConnect(playerid)
{
    new ip[16], playername[24];
    GetPlayerIp(playerid, ip, 16);
    GetPlayerName(playerid, playername, 24);
    printf("%s (ID: %i) (IP: %s) has joined the server!", playername, playerid, ip);
    PlayerCount++;
    printf("Total players connected since server startup: %i",PlayerCount);
    return 1;
}



Re: Command Log - SanAndreasVille - 26.02.2011

thx woks!

now i want when my server starts print the Date/Year in the Server Log,

(Server successfully starts 26.02.2011)

can everyone help


Re: Command Log - MP2 - 26.02.2011

https://sampwiki.blast.hk/wiki/Getdate
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/printf


Re: Command Log - SanAndreasVille - 26.02.2011

print("Server startet: %02d/%02d/%d", Day, Month, Year);

have 3 Warnings :

Код:
E:\pwn(518) : warning 202: number of arguments does not match definition
E:\pwn(518) : warning 202: number of arguments does not match definition
E:\pwn(518) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.



Re: Command Log - MP2 - 26.02.2011

printf