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

"Unregister" or block command?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-29-2014 , 19:25   "Unregister" or block command?
Reply With Quote #1

Is there a way to "take over" a command registered by another plugin without putting my plugin above the one registering it in plugins.ini? Or if not, is there a way to block that command?

I have my own plugin which uses amx_ban and another alternative command for the same function. I want to block the amx_ban command from admincmd so that only the alternative command from my plugin works if it is not above admincmd in plugins.ini (if it is, both will work).
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
jok
Member
Join Date: Sep 2013
Old 03-29-2014 , 20:39   Re: "Unregister" or block command?
Reply With Quote #2

if I got you right:
disassemble the plugin (can only be done if it was compiled before latest amxmodx version) and read the strings for possible commands.

Last edited by jok; 03-29-2014 at 20:40.
jok is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-29-2014 , 20:48   Re: "Unregister" or block command?
Reply With Quote #3

Just remove the register_concmd line from the plugin that registers it
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-29-2014 , 20:53   Re: "Unregister" or block command?
Reply With Quote #4

Code:
public client_command(id) {     new command[9];     read_argv(0, command, charsmax(command));     if ( equali(command, "amx_ban") ) {                 // Your code instead of amx_ban.                 return PLUGIN_HANDLED;     }     return PLUGIN_CONTINUE; }
__________________

Last edited by Black Rose; 03-30-2014 at 10:05.
Black Rose is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-30-2014 , 08:29   Re: "Unregister" or block command?
Reply With Quote #5

Quote:
Originally Posted by Black Rose View Post
Code:
public client_command(id) {
     new command[9];
     read_argv(0, command, charsmax(command));
     if ( equali(command, "amx_ban" ) {

             // Your code instead of amx_ban.

             return PLUGIN_HANDLED;
     }
     return PLUGIN_CONTINUE;
 }
That will not prevent the original amx_ban from executing. The player will already be kicked when my function starts.
Quote:
Originally Posted by YamiKaitou View Post
Just remove the register_concmd line from the plugin that registers it
Replacing another plugin is harder than just putting mine first in plugins.ini.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-30-2014 , 08:39   Re: "Unregister" or block command?
Reply With Quote #6

Quote:
Originally Posted by Desikac View Post
Replacing another plugin is harder than just putting mine first in plugins.ini.
Since you have the source code for the plugin that you want to block, just edit it.

If you still do not want to edit the plugin, then put your plugin above the other and simply return PLUGIN_HANDLED to prevent the execution of the other plugin
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-30-2014 , 08:50   Re: "Unregister" or block command?
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
Since you have the source code for the plugin that you want to block, just edit it.

If you still do not want to edit the plugin, then put your plugin above the other and simply return PLUGIN_HANDLED to prevent the execution of the other plugin
The problem is, people who download my plugin don't put it above, regardless of big red letters below the download link.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-30-2014 , 08:59   Re: "Unregister" or block command?
Reply With Quote #8

Then that is their problem, not yours.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-30-2014 , 10:05   Re: "Unregister" or block command?
Reply With Quote #9

Quote:
Originally Posted by Desikac View Post
That will not prevent the original amx_ban from executing. The player will already be kicked when my function starts.
Replacing another plugin is harder than just putting mine first in plugins.ini.
Yes it will. I don't just take guesses to collect posts.
Without plugin:
Code:
] amx_ban test
Usage:  amx_ban <name or #userid> <minutes> [reason]
] amx_kick test
Client with that name or userid not found
With plugin:
Code:
] amx_ban test
] amx_kick test
Client with that name or userid not found

Code:
server_print("plugin_init() admincmd")
Code:
server_print("plugin_init() custom plugin")
Code:
plugin_init() admincmd
plugin_init() custom plugin
__________________

Last edited by Black Rose; 03-30-2014 at 10:10.
Black Rose is offline
Desikac
Senior Member
Join Date: Apr 2010
Location: Serbia
Old 03-30-2014 , 11:54   Re: "Unregister" or block command?
Reply With Quote #10

^
Lol it actually works.
Though I still don't understand how come.
Desikac is offline
Send a message via MSN to Desikac Send a message via Skype™ to Desikac
Reply



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 13:16.


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