AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   "Unregister" or block command? (https://forums.alliedmods.net/showthread.php?t=237811)

Desikac 03-29-2014 19:25

"Unregister" or block command?
 
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).

jok 03-29-2014 20:39

Re: "Unregister" or block command?
 
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.

YamiKaitou 03-29-2014 20:48

Re: "Unregister" or block command?
 
Just remove the register_concmd line from the plugin that registers it

Black Rose 03-29-2014 20:53

Re: "Unregister" or block command?
 
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; }

Desikac 03-30-2014 08:29

Re: "Unregister" or block command?
 
Quote:

Originally Posted by Black Rose (Post 2117693)
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 (Post 2117692)
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.

YamiKaitou 03-30-2014 08:39

Re: "Unregister" or block command?
 
Quote:

Originally Posted by Desikac (Post 2117866)
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

Desikac 03-30-2014 08:50

Re: "Unregister" or block command?
 
Quote:

Originally Posted by YamiKaitou (Post 2117868)
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.

YamiKaitou 03-30-2014 08:59

Re: "Unregister" or block command?
 
Then that is their problem, not yours.

Black Rose 03-30-2014 10:05

Re: "Unregister" or block command?
 
Quote:

Originally Posted by Desikac (Post 2117866)
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


Desikac 03-30-2014 11:54

Re: "Unregister" or block command?
 
^
Lol it actually works.
Though I still don't understand how come. :D


All times are GMT -4. The time now is 05:58.

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