Page 1 of 1

[TUT] A way to hook say commands and using in commands

Posted: Fri Sep 25, 2026 5:17 pm
by Archive-Poster
Hello, i tried to search any tutorial talking about how to hook a say command and using it as command in console, but i don't found in forum.
This tutorial will about it using a commands in messagemode like: .kick, .ban and other commands if you need.

First, hook a say command or say_team in plugin_init()

Code: Select all

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    register_plugin("Say Commands","0.0.1","SmileY");
    
    register_clcmd("say","cmdSAY");
    register_clcmd("say_team","cmdSAY");
}

public cmdSAY(id)
{
    new Args[192];
    read_args(Args,charsmax(Args));    // Hook the args in a global say or say_team command
    remove_quotes(Args);
    
    // if contain a symbol in a begin of string, then use like as console command
    if(Args[0] == '.' /*Add Here your style of commands, like '.' or '!' for example*/)
    {
        client_cmd(id,Args);

        return PLUGIN_HANDLED;
    }
    return PLUGIN_CONTINUE;
} 
The second part basics you need to register command in a plugin_init() using the symbol of your choiced:

Code: Select all

register_clcmd(".kill","cmdKill",ADMIN_SLAY,"<Name | #id>"); 
And finally any function for your registred command:

Code: Select all

// Remember: This function is registred in console and has a .kill command!

public cmdKill(id,level,cid)     // And done, use your function like in console xD
{
    if(!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED;
    
    new Arg[32];
    read_argv(1,Arg,charsmax(Arg));
    
    new iPlayer = cmd_target(id,Arg,CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE);
    
    if(!iPlayer) return PLUGIN_HANDLED;
    
    new szName[2][32];
    get_user_name(id,szName[0],charsmax(szName[]));
    
    get_user_name(iPlayer,szName[1],charsmax(szName[]));
    
    user_silentkill(iPlayer);
    
    client_print(0,print_chat,"* %s has ninja killed %s",szName[0],szName[1]);
    
    return PLUGIN_HANDLED;
} 
Ending:
If your like to register all commands in another plugin its works!