Raised This Month: $12 Target: $400
 3% 

[ANY] Plugin not logging commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NotApollyon093
Junior Member
Join Date: Mar 2019
Location: Spokane, WA
Old 08-08-2020 , 15:17   [ANY] Plugin not logging commands
Reply With Quote #1

I'm working on some old code that no longer seems to do it's job. Can anyone spot the error? It's supposed to be logging all executed commands to a folder.
Code:
Code:
#pragma semicolon 1
#include <sourcemod>


new String:ClientSteamID[MAXPLAYERS+1][60];

public Plugin:myinfo = 
{
  name = "Log all executed commands by players",
  author = "Seather + Dyl0n + [FJC] Apollyon094",
  description = "displays on server console and logs sourcemod commands executed by players",
  version = "0.0.2",
  url = "http://www.sourcemod.net/"
}; 


public OnPluginStart()
{
    HookAll(1);
}

HookAll(mode)
{
    decl String:name[64];
    new Handle:cvar, bool:isCommand, flags;
    new commandCount = 0;
    
    //Fetch first command
    cvar = FindFirstConCommand(name, sizeof(name), isCommand, flags);
    if (cvar == INVALID_HANDLE)
    {
        SetFailState("Could not load cvar list");
    }
    
    //Process + get more loop
    do
    {
        //get rid of cvars
        if (!isCommand)
        {
            continue;
        }
        commandCount++;
        
        //PrintToServer("[show command] hook: %s", name);
        new count = sizeof(name);
        //Hook Command
        if(mode == 1) {
            if(count-3 > -1)
            {
                if(name[0] + name[1] + name[2] == 's' + 'm' + '_')
                {
                    if(name[count-4] + name[count-3] + name[count-2] + name[count-1] != '.' + 's' + 'm' + 'x')
                    {
                            RegConsoleCmd(name, Command_All);
                            RegServerCmd(name, Command_SV);
                    }
                }
            }
        }
        
    } while (FindNextConCommand(cvar, name, sizeof(name), isCommand, flags));

    CloseHandle(cvar);
}

//hooked in OnPluginStart
public Action:Command_All(client, args)
{
    if(client != 0)
    {
        decl String:cmdname[128];
        GetCmdArg(0, cmdname, sizeof(cmdname));
        decl String:argstr[128];
        GetCmdArgString(argstr, sizeof(argstr));
        new String:PlayerInfo[60];
        new String:PlayerName[32];
        GetClientAuthId(client, AuthId_Steam2, PlayerInfo, sizeof(PlayerInfo));
        strcopy(ClientSteamID[client], 60, PlayerInfo);
        GetClientName(client, PlayerName, 31);

        LogToFile("sourcemod/logs/execcommands.log", "%s [%s] %s %s", PlayerName, ClientSteamID[client], cmdname, argstr);
        //PrintToServer("[show method 1] <%i> %s %s", client, cmdname, argstr);
    }
    
    return Plugin_Continue;
}

//hooked in OnPluginStart with server hook
public Action:Command_SV(args)
{
    decl String:cmdname[128];
    GetCmdArg(0, cmdname, sizeof(cmdname));
    decl String:argstr[128];
    GetCmdArgString(argstr, sizeof(argstr));

    LogToFile("sourcemod/logs/execcommands.log", "cmd: %s args: %s", cmdname, argstr);
    //PrintToServer("[show method 4] <-> %s %s", cmdname, argstr);
    
    return Plugin_Continue;
}
Only stopped working after updating sourcemod after a long time
NotApollyon093 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode