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=267273)
Command Log -
ludesert - 07.07.2011
Hello, I'm looking for a command log, like a Chat Log, but for commands.
I made a Chat Log with
this tutorial and it works perfectly.
Now, I tryed to use this tutorial to do a command log, but it doesn't work. Does anybody know how to make a command log ?
Thanks =)
Re : Command Log -
ludesert - 07.07.2011
Nobody ?
Re: Re : Command Log -
Cameltoe - 07.07.2011
Quote:
Originally Posted by ludesert
Nobody ?
|
What command system are you using ?
Re: Command Log -
ludesert - 07.07.2011
Dcmd and zcmd
Re: Command Log -
Cameltoe - 07.07.2011
Quote:
Originally Posted by ludesert
Dcmd and zcmd
|
Both ? I thought Zcmd block's the OnPlayerCommandText?
Though, here's how to output zcmd commands :
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
return Log(cmdtext); // probably do some formating to output the player name etc.
}
Re: Command Log -
ludesert - 07.07.2011
No. But do you know how to make a command log ?
Re: Command Log -
Cameltoe - 07.07.2011
Quote:
Originally Posted by ludesert
No. But do you know how to make a command log ?
|
Yes,
pawn Код:
stock Log(Text[])
{
new Query[130];
format(Query, sizeof(Query), "INSERT INTO logs (id, text) VALUES (NULL, '%s');", Text);
mysql_query(Query);
}
Besides stripping the Text for mysql injections, this is how i would do it.
Re: Command Log -
ludesert - 07.07.2011
Is it possible to create a log of thй commands whitch were used un a txt file like that :
[day] [mounth] [hour] [minut] : player : command
?
Re: Command Log -
WoodPecker - 07.07.2011
Add this on the OnPlayerCommandText
Код:
new cmd[128];
cmd = strtok(cmdtext, idx);
printf("[cmd][%s]: %s",PlayerName(playerid),cmdtext);
Re: Command Log -
Cameltoe - 08.07.2011
Quote:
Originally Posted by ******
What is it with people recently assuming that people use MySQL - I've seen it in an increasing number of topics. The OP asks a perfectly normal question and doesn't mention MySQL at any point; at no point do they say they have it installed, have it set up or have any interest in using it at all; yet answers start using it.
MySQL, like ALL plugins, is non-standard. If you are going to use it at least mention that "this will require you to install a massive great library designed for huge websites on to your tiny little SA:MP server which already has perfectly good database functionality built in, just for one line of code" (or words to that effect). You cannot assume that people have any plugins installed, even common ones like sscanf should be explicitly stated.
|
Quote:
Originally Posted by ludesert
No. But do you know how to make a command log ?
|
Quote:
Originally Posted by Cameltoe
Yes,
pawn Код:
stock Log(Text[]) { new Query[130]; format(Query, sizeof(Query), "INSERT INTO logs (id, text) VALUES (NULL, '%s');", Text); mysql_query(Query); }
Besides stripping the Text for mysql injections, this is how i would do it.
|
He asked me if i knew how to script and command log, and basicly that's how i would do it, i did not assume Ludesert were using mysql at all.
Anyway, this should work :
pawn Код:
// Zcmd
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
CommandLog(playerid, cmdtext);
return 1;
}
// Strcmp
public OnPlayerCommandText(playerid, cmdtext[])
{
CommandLog(playerid, cmdtext);
return 1;
}
stock CommandLog(playerid, text[])
{
new
File:lFile = fopen("Logs/CommandLog.txt", io_append),
logData[178],
fyear, fmonth, fday,
fhour, fminute, fsecond;
getdate(fyear, fmonth, fday);
gettime(fhour, fminute, fsecond);
format(logData, sizeof(logData),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", fday, fmonth, fyear, fhour, fminute, fsecond, GetName(playerid), text);
fwrite(lFile, logData);
fclose(lFile);
return 1;
}
stock GetName(playerid)
{
new pName[25];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}