- This log all commands what
AddCommandListener can recognize.
- New log file is created every time when plugin loaded.
PHP Code:
char path[PLATFORM_MAX_PATH];
public void OnPluginStart()
{
// Set plugin in Fail state if this feature is missing.
RequireFeature(FeatureType_Capability, FEATURECAP_COMMANDLISTENER,
"Unfortunately 'AddCommandListener' is not supported in this game or SourceMod version.");
// Listen all commands
AddCommandListener(cmdlistener, "");
FormatTime(path, sizeof(path), "%Y-%m-%d %H%M");
BuildPath(Path_SM, path, sizeof(path), "logs/CMD_%s.txt", path);
}
public Action cmdlistener(int client, const char[] command, int argc)
{
char sarg[255];
GetCmdArgString(sarg, sizeof(sarg));
char buffer[40];
// client indexes
if(client > 0 && client <= MaxClients && IsClientConnected(client))
{
int userid = GetClientUserId(client);
GetClientAuthId(client, AuthId_Engine, buffer, sizeof(buffer));
Format(buffer, sizeof(buffer), "#%-5i %s", userid, buffer);
}
LogToFileEx(path, "%25s - %s '%s'", buffer, command, sarg);
return Plugin_Continue;
}
output
Code:
L 01/30/2021 - 18:00:01: - exec 'skill1.cfg'
L 01/30/2021 - 18:00:01: - exec 'server.cfg'
L 01/30/2021 - 18:00:01: - exec 'sourcemod/sourcemod.cfg'
L 01/30/2021 - 18:00:01: - exec 'sourcemod\basevotes.cfg'
L 01/30/2021 - 18:00:01: - exec 'sourcemod\funcommands.cfg'
L 01/30/2021 - 18:00:01: - exec 'sourcemod\funvotes.cfg'
L 01/30/2021 - 18:00:01: - sm_internal '1'
L 01/30/2021 - 18:00:25: #4 [U:1:28327177] - vmodenable '1'
L 01/30/2021 - 18:00:25: #4 [U:1:28327177] - vban '0 0 0'
L 01/30/2021 - 18:00:26: #4 [U:1:28327177] - joingame ''
L 01/30/2021 - 18:00:26: #4 [U:1:28327177] - jointeam '0'
L 01/30/2021 - 18:00:27: #4 [U:1:28327177] - joinclass '0'
L 01/30/2021 - 18:00:53: #4 [U:1:28327177] - drop ''
L 01/30/2021 - 18:01:04: #4 [U:1:28327177] - drop ''
L 01/30/2021 - 18:01:30: #4 [U:1:28327177] - fallback ''
L 01/30/2021 - 18:01:33: #4 [U:1:28327177] - roger ''
L 01/30/2021 - 18:01:35: #4 [U:1:28327177] - coverme ''
L 01/30/2021 - 18:04:05: #7 [U:1:28327177] - vmodenable '1'
L 01/30/2021 - 18:04:06: #7 [U:1:28327177] - joingame ''
L 01/30/2021 - 18:04:06: #7 [U:1:28327177] - jointeam '0'
L 01/30/2021 - 18:04:07: #7 [U:1:28327177] - joinclass '0'
L 01/30/2021 - 18:04:15: #7 [U:1:28327177] - say '"/admin"'
L 01/30/2021 - 18:04:15: #7 [U:1:28327177] - sm_admin ''
L 01/30/2021 - 18:04:19: #7 [U:1:28327177] - menuselect '1'
L 01/30/2021 - 18:04:20: #7 [U:1:28327177] - menuselect '1'
L 01/30/2021 - 18:04:21: #7 [U:1:28327177] - menuselect '1'
L 01/30/2021 - 18:04:22: #7 [U:1:28327177] - menuselect '1'
L 01/30/2021 - 18:04:23: #7 [U:1:28327177] - menuselect '1'
L 01/30/2021 - 18:04:32: #7 [U:1:28327177] - say '"!admin"'
L 01/30/2021 - 18:04:32: #7 [U:1:28327177] - sm_admin ''
L 01/30/2021 - 18:05:18: #7 [U:1:28327177] - timeleft ''
If you want only chat commands, change code
Code:
this AddCommandListener(cmdlistener, "");
to
AddCommandListener(cmdlistener, "say");
AddCommandListener(cmdlistener, "say_team");
I don't know exactly, what are chat commands in NMRIH
__________________