How to log command usages -
Tamer - 06.01.2013
Hey guys,I want to log some admin commands when they are used. I checked out a few scripts that log,but couldn't get it.
I don't want it to printf as the server log gets very huge. I want it to log them on another notepad file.
Can someone tell me how to log easily on this /armour command.
It will log to a notepad called "admincommands" and will print in the player name admin name and the command used.
Thanks!
Ofcourse +repp'ing!
Re: How to log command usages -
park4bmx - 06.01.2013
ok i made u a very easy function to use.
it saves a file called
CMDLog.txt in your
scriptfiles and using
Y_INI
pawn Код:
stock LogPlayerCmd(playerid,cmdtext[])
{
new name[MAX_PLAYER_NAME], file[80],fStr[90],tStr[30];
GetPlayerName(playerid, name, sizeof(name));
//
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
format(tStr,sizeof tStr,"[%02d:%02d:%02d]",Hour, Minute, Second);
format(fStr,sizeof fStr,"%s: %s",name,cmdtext);
//
new INI:Acc = INI_Open("CmdLog.txt");
INI_WriteString(Acc,tStr, fStr);
INI_Close(Acc);
return 1;
}
is easy to use. for example in your command above all you have to do is add this
pawn Код:
LogPlayerCmd(playerid,"armour");
and that will save a file called
"CmdLog.txt" and will have the time that the player send the cmd and the name and the cmd he typed.
NOTE if the players spams the cmd it will overweight the last cmd by him
Re: How to log command usages -
eesh - 06.01.2013
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success)
{
new name[32];
GetPlayerName(playerid, name, 32);
printf("%s performed command %s", name, cmdtext);
return 1;
}
return 1;
}
Put this somewhere in the end. Easier than what the guy above posted.
Re: How to log command usages -
park4bmx - 06.01.2013
Quote:
Originally Posted by eesh
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success)
{
new name[32];
GetPlayerName(playerid, name, 32);
printf("%s performed command %s", name, cmdtext);
return 1;
}
return 1;
}
Put this somewhere in the end. Easier than what the guy above posted.
|
huh, read again sir
Quote:
Originally Posted by Tamer T
I don't want it to printf as the server log gets very huge. I want it to log them on another notepad file.
|
Re: How to log command usages -
eesh - 06.01.2013
Opps my bad. Here our combined efforts(even though your effort was 90% more):
Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success)
{
LogPlayerCmd(playerid,cmdtext);
}
return 1;
}
stock LogPlayerCmd(playerid,cmdtext[])
{
new name[MAX_PLAYER_NAME], file[80],fStr[90],tStr[30];
GetPlayerName(playerid, name, sizeof(name));
//
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
format(tStr,sizeof tStr,"[%02d:%02d:%02d]",Hour, Minute, Second);
format(fStr,sizeof fStr,"%s: %s",name,cmdtext);
//
new INI:Acc = INI_Open("CmdLog.txt");
INI_WriteString(Acc,tStr, fStr);
INI_Close(Acc);
return 1;
}
This way you dont have to add that line under every command
.
Re: How to log command usages -
Tamer - 06.01.2013
Thanks both of your effort but I got an error.
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(513) : warning 204: symbol is assigned a value that is never used: "file"
--I tried with both of your code,same error.
I think I need to make it same with my name of "file" on my script but I couldn't find it,help?
Re: How to log command usages -
Mr.Anonymous - 06.01.2013
Remove
file[80].
Re: How to log command usages -
Tamer - 06.01.2013
Alright it worked thanks
But it logs it like this:
[14:32:36] = [AVT]Tamer: /armour 0
Is it possible for it to log,command user name,command and used on who?
Edit:
Actually nevermind,It is ok this way!