SA-MP Forums Archive
Upon typing a command, a log is made. - 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)
+--- Thread: Upon typing a command, a log is made. (/showthread.php?tid=386195)



Upon typing a command, a log is made. - davelord - 19.10.2012

Hi there. Could someone help me with a simple log system? For example, if a command is typed, it saves in a specific folder, as a .txt, and for example: [name] [command] [variables] <- could anyone help me or give me a example on how to do it?


Re: Upon typing a command, a log is made. - Lordzy - 19.10.2012

Wrong section.
Must be on Script Request Thread.

Btw, here's the snippet.

PHP код:
new File:cmdlog;
public 
OnPlayerCommandText(playerid,cmdtext[])
{
  new 
string[128];
  new 
Lname[MAX_PLAYER_NAME];
  
GetPlayerName(playerid,Lname,sizeof(Lname));
  
format(string,sizeof(string),"%s has used the command (%s) \r\n"Lnamecmdtext);
  
cmdlog fopen("CMD_Logs.txt"io_append);
  
fwrite(cmdlog,string);
  
fclose(cmdlog);
  return 
0;




Re: Upon typing a command, a log is made. - davelord - 19.10.2012

I only asked for a example, but thanks! ^^


Re: Upon typing a command, a log is made. - Lordzy - 19.10.2012

Np, btw I edited my snippet because the previous one will save the text like this :
Код:
Lordz has used the command (/example) Lordz has used the command (/example2)
The edited one will be saving like this:
Код:
Lordz has used the command (/example)
Lordz has used the command (/example2)