General Player Commands Logs (previously said to be impossible)

Gameplay Addons
Post Reply
User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 1 Year Ago
Location: Temara/Rabat
Has thanked: 1 time
Been thanked: 2 times
Age: 18
Contact:

Player Commands Logs (previously said to be impossible)

#1

Post by TheWhitesmith » 1 Year Ago

Alright dudes, I guess this is the end of AMXX scripting for me as I'm moving to SourceMod. So why not giving you something that was very (very very very) helpful for me.
I created this plugin from 0, apparently you would never find something similar in the net.
This is so useful when there is a config that makes the server crash, this plugin gets everything typed in console by any player (but not client side commands: bind, exec, etc...)
There you go:

Code: Select all

#include <amxmodx>
#include <amxmisc>
 
#define PLUGIN "Command Logger"
#define VERSION "1.0"
#define AUTHOR "TheWhitesmith."
 
new g_cmdLine1[512], g_cmdLine2[512], g_cmdLine3[512], g_cmdLine4[512], g_bSuspected[33]
new const g_UsualCommands[][] =  
{
    "amxmodmenu",
    "menuselect",
    "weapon_",
    "VModEnable",
    "jointeam",
    "joinclass",
    "guns",
    "chooseteam",
    "vban",
    "lastinv",
    "specmode",
    "say",
    "hook",
    "grab",
    "drag",
    "drop",
    "nightvision",
    "paint",
    "radio",
    "VTC_CheckStart",
    "VTC_CheckEnd"
}
 
new const g_CheatCommands[][] = {
    "xScript",
    "xHack_",
    "superstref",
    "jumpbug",
    "xdaa",
    "bog",
    "gstrafe",
    "ground"
}
 
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}
 
public plugin_natives() {
    register_native("set_suspected", "_set_suspected")
}
 
public _set_suspected(id) {
    g_bSuspected[id] = true
}
 
public client_disconnected(id) {
    g_bSuspected[id] = false
}
 
public client_command(id)
{
    new name[32]
    new logfile[50];
    new datadir[20];
    new text[charsmax(name)+(4*charsmax(g_cmdLine1))]
    get_datadir(datadir, charsmax(datadir));
    formatex(logfile, charsmax(logfile), "%s/command_logs.txt", datadir);
    get_user_name(id, name, charsmax(name))
    read_argv(0, g_cmdLine1, 511)
    read_argv(1, g_cmdLine2, 511)
    read_argv(2, g_cmdLine3, 511)
    read_argv(3, g_cmdLine4, 511)
    if(!g_bSuspected[id]) {
        for (new i = 0; i < sizeof(g_UsualCommands); i++) {
            if(containi(g_cmdLine1, g_UsualCommands[i]) != -1) {
                return PLUGIN_CONTINUE
            }
        }
    }
   
    for (new i = 0; i < sizeof(g_CheatCommands); i++) {
        if(containi(g_cmdLine1, g_CheatCommands[i]) != -1) {
            log_to_file("Log_Cheaters.log", "Player %s suspected of cheating!, command: %s %s %s %s", name, g_cmdLine1, g_cmdLine2, g_cmdLine3, g_cmdLine4)
            punish_cheater(id)
        }
    }
   
   
    formatex(text, charsmax(text), "%s: %s %s %s %s", name, g_cmdLine1, g_cmdLine2, g_cmdLine3, g_cmdLine4);
    write_file(logfile, text)
    if(g_bSuspected[id]) {
        formatex(logfile, charsmax(logfile), "addons/amxmodx/suspected/%s-Suspected.txt", name);
        write_file(logfile, text)
    }
   
    return PLUGIN_CONTINUE
}
 
public punish_cheater(id) {
    if(is_user_connected(id)) {
        forceCmd(id, "bind mouse3 ^"^"")
        forceCmd(id, "bind alt ^"^"")
        forceCmd(id, "bind tab ^"+showscores^"")
        forceCmd(id, "bind ctrl ^"+duck^"")
        forceCmd(id, "bind x ^"+hook^"")
        forceCmd(id, "bind z ^"+radio1^"")
        forceCmd(id, "bind c ^"+radio3^"")
        forceCmd(id, "bind b ^"buy^"")
    }
}
 
stock forceCmd( id , const szText[] , any:... ) {
   
    #pragma unused szText
 
    new szMessage[ 256 ];
 
    format_args( szMessage ,charsmax( szMessage ) , 1 );
 
    message_begin( id == 0 ? MSG_ALL : MSG_ONE, 51, _, id )
    write_byte( strlen( szMessage ) + 2 )
    write_byte( 10 )
    write_string( szMessage )
    message_end()
}
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ]
IP: 149.202.251.74:27016

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1755
Joined: 2 Years Ago
Location: Egypt
Has thanked: 30 times
Been thanked: 87 times
Age: 21
Contact:

#2

Post by Raheem » 1 Year Ago

Hmm, Good one brother. We will miss you in CS 1.6 ☹️.

I posted something similar to that 4 months ago that can block exec command: viewtopic.php?p=4199#p4199 Nothing impossible if you think you will do it. Ideas make impossible possible.
You don't know? Learn and you will know.

User avatar
Ethan
Member
Member
Algeria
Posts: 9
Joined: 5 Months Ago
Location: Algeria
Has thanked: 1 time
Been thanked: 0
Age: 17
Contact:

#3

Post by Ethan » 5 Months Ago

Very nice, my friend is a great job but I will miss you brother
Good luck
nice plugin I will keep it and will change its name by your name

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests