[STOCK] Register say commands like Sourcemod
Posted: Sun Oct 04, 2026 2:46 pm
If you played any sourcemod game you know ( for example L4D2 buy system ) that you can use 5 commands to do the same thing.
sm_buy - A console command that never spams the chat if used ( like a key bind ).
say /buy - A chat command that doesn't spam the chat UNLESS you miss spell of course or if you press a key bind by mistake.
say_team /buy - Same for say /buy but prints only to team ( Duh... )
say !buy - A chat command that spams the chat if you type it. When people use it eventually all commands are noticed by new players.
say_team !buy - Same for say_team !buy but prints only to team ( Duh... )
So I converted it to AmxModX and I hope all plugins will use it for commands.
How it works:
register_amxxcmd("amxx_buy", "PublicOfBuy"); // Registers the 5 commands but amxx_buy replaces sm_buy because this isn't Sourcemod...
register_amxxcmd("say /buy", "PublicOfBuy"); // Registers just 1 command and behaves EXACTLY like register_clcmd, useless but meh...
Code:
sm_buy - A console command that never spams the chat if used ( like a key bind ).
say /buy - A chat command that doesn't spam the chat UNLESS you miss spell of course or if you press a key bind by mistake.
say_team /buy - Same for say /buy but prints only to team ( Duh... )
say !buy - A chat command that spams the chat if you type it. When people use it eventually all commands are noticed by new players.
say_team !buy - Same for say_team !buy but prints only to team ( Duh... )
So I converted it to AmxModX and I hope all plugins will use it for commands.
How it works:
register_amxxcmd("amxx_buy", "PublicOfBuy"); // Registers the 5 commands but amxx_buy replaces sm_buy because this isn't Sourcemod...
register_amxxcmd("say /buy", "PublicOfBuy"); // Registers just 1 command and behaves EXACTLY like register_clcmd, useless but meh...
Code:
Code: Select all
stock register_amxxcmd(const client_cmd[],const function[],flags=-1, const info[]="", FlagManager=-1)
{
if(!equali(client_cmd, "amxx_", 5))
return register_clcmd(client_cmd, function, flags, info, FlagManager);
new Format[40];
register_clcmd(client_cmd, function, flags, info, FlagManager);
register_clcmd(client_cmd, "Block_Chat_Command_69420", flags, info, FlagManager); // This one blocks Unknown Command.
formatex(Format, charsmax(Format), client_cmd);
replace(Format, charsmax(Format), "amxx_", "say !");
register_clcmd(Format, function, flags, info, FlagManager);
replace(Format, charsmax(Format), "say !", "say_team !");
register_clcmd(Format, function, flags, info, FlagManager);
replace(Format, charsmax(Format), "say_team !", "say /");
register_clcmd(Format, function, flags, info, FlagManager);
register_clcmd(Format, "Block_Chat_Command_69420", flags, info, FlagManager);
replace(Format, charsmax(Format), "say /", "say_team /");
register_clcmd(Format, function, flags, info, FlagManager);
register_clcmd(Format, "Block_Chat_Command_69420", flags, info, FlagManager);
return 0;
}
public Block_Chat_Command_69420(id) return 1;