Raised This Month: $32 Target: $400
 8% 

[STOCK] Register say commands like Sourcemod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-30-2017 , 15:29   [STOCK] Register say commands like Sourcemod
Reply With Quote #1

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:

PHP Code:
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, flagsinfoFlagManager);
    
    new 
Format[40];
    
register_clcmd(client_cmd, function, flagsinfoFlagManager);
    
register_clcmd(client_cmd"Block_Chat_Command_69420"flagsinfoFlagManager); // This one blocks Unknown Command.
    
    
formatex(Formatcharsmax(Format), client_cmd);
    
    
replace(Formatcharsmax(Format), "amxx_""say !");
    
register_clcmd(Format, function, flagsinfoFlagManager);
    
    
replace(Formatcharsmax(Format), "say !""say_team !");
    
register_clcmd(Format, function, flagsinfoFlagManager);
    
    
replace(Formatcharsmax(Format), "say_team !""say /");
    
register_clcmd(Format, function, flagsinfoFlagManager);
    
register_clcmd(Format"Block_Chat_Command_69420"flagsinfoFlagManager);
    
    
replace(Formatcharsmax(Format), "say /""say_team /");
    
register_clcmd(Format, function, flagsinfoFlagManager);
    
register_clcmd(Format"Block_Chat_Command_69420"flagsinfoFlagManager);
    
    return 
0;
}

public 
Block_Chat_Command_69420(id) return 1
I hope you like it!
eyal282 is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 05-30-2017 , 19:19   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #2

there is already a commande for this called register_clcmd
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality
yas17sin is offline
Send a message via ICQ to yas17sin
kristi
Senior Member
Join Date: Nov 2016
Old 05-30-2017 , 19:27   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #3

In amxx commands by default are amx_ ..

Last edited by kristi; 05-30-2017 at 19:27.
kristi is offline
Send a message via Skype™ to kristi
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-30-2017 , 19:28   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #4

Quote:
Originally Posted by yas17sin View Post
there is already a commande for this called register_clcmd
That registers amxx_command, say /command ( return 1; ), say_team /command ( return 1; ), say !command ( return 0; ), say_team !command ( return 0; ) without needing to do all the s**** without a comfortable stock?
eyal282 is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 05-30-2017 , 21:31   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #5

well a good stock is not harmful . Gj.
__________________
FINISHED WORKING ON : Attack On Titan Mod (100% Done).

FB Acc : FaceBook Account.

pic: http://prntscr.com/fszkke not good quality
yas17sin is offline
Send a message via ICQ to yas17sin
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-31-2017 , 06:55   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #6

your code has no sense
Craxor is offline
Send a message via ICQ to Craxor
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-31-2017 , 07:30   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #7

PHP Code:
public Block_Chat_Command_69420(id) return 1
Remove that, the command should be properly handled in it's callback(i.e the coder must return the appropiate value).
__________________
HamletEagle is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-31-2017 , 08:27   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
PHP Code:
public Block_Chat_Command_69420(id) return 1
Remove that, the command should be properly handled in it's callback(i.e the coder must return the appropiate value).
The point is to always return 1 so when / is used, the command is invisible and visible when ! Is used, similar to sourcemod.
eyal282 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-31-2017 , 08:38   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #9

But you are registering it on the base comand too, which is used from console.
__________________
HamletEagle is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-31-2017 , 08:41   Re: [STOCK] Register say commands like Sourcemod
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
But you are registering it on the base comand too, which is used from console.
In the requested function the coder returns 0 and every / is also returned 1.
eyal282 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 08:01.


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