PDA

View Full Version : [Solved] chat record


phoenix0001
01-29-2021, 13:09
Any commands entered by the player [! Admin,/admin] etc..

The server can record and save to a text [like the record in the logo, one text per day, addons\ sourceMods \logs]

Also record the player's Steamid steam_0:0:12 3456789

I want to see what commands the player has typed


Such as:

01/30/2021-00:37:06: [steam_0:0:123456789] command /admin

01/30/2021-00:38:06: [steam_0:0:123344556] command !admin

01/30/2021-00:39:06: [steam_0:0:0011223] command /VIP



Since some players have been messing up the server recently, I want to find out who is doing it.

Bacardi
01-30-2021, 11:11
- This log all commands what AddCommandListener can recognize.
- New log file is created every time when plugin loaded.

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

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
this AddCommandListener(cmdlistener, "");
to

AddCommandListener(cmdlistener, "say");
AddCommandListener(cmdlistener, "say_team");
I don't know exactly, what are chat commands in NMRIH

phoenix0001
01-30-2021, 12:04
- This log all commands what AddCommandListener can recognize.
- New log file is created every time when plugin loaded.

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

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
this AddCommandListener(cmdlistener, "");
to

AddCommandListener(cmdlistener, "say");
AddCommandListener(cmdlistener, "say_team");
I don't know exactly, what are chat commands in NMRIH

I'm very much obliged to you
This is exactly what i want