AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Redefine/Override methods? (https://forums.alliedmods.net/showthread.php?t=116540)

rjckE 01-23-2010 22:20

Redefine/Override methods?
 
Hi guys. A simple question here.

Does PAWN/AMX allow to redefine methods?

I mean, supose i'm using admincmd.amxx in my server, and i do a plugin foo.amxx where i register a console command called amx_kick

PHP Code:

    register_concmd("amx_kick""cmdKick"ADMIN_KICK"<name or #userid> [reason]"

and the method cmdKick is something like this:

PHP Code:

public cmdKick(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
if (MY_CONDITION)
      return 
PLUGIN_HANDLED
    
else
      return 
PLUGIN_CONTINUE


If i do amx_kick, which amx_kick will amx use? the one from admincmd or the one from foo.amxx?

Thanks

YamiKaitou 01-23-2010 22:26

Re: Redefine/Override methods?
 
It will use any that do not get blocked. The call order is based on the order the plugins are registered, ie placed in the plugins.ini file. So, if you want to make sure yours is called, put it above any other plugin that registers the same command(s).

rjckE 01-23-2010 22:30

Re: Redefine/Override methods?
 
so if i place foo.amxx before admincmd.amxx in plugins.ini it will call to cmdKick of foo.amxx and then to cmdKick of admincmd.amxx?

thanks for the reply!

YamiKaitou 01-23-2010 22:38

Re: Redefine/Override methods?
 
Quote:

Originally Posted by rjckE (Post 1065190)
so if i place foo.amxx before admincmd.amxx in plugins.ini it will call to cmdKick of foo.amxx and then to cmdKick of admincmd.amxx?

Correct. But, if you return PLUGIN_HANDLED in foo.amxx, admincmd.amxx won't get called

rjckE 01-23-2010 22:47

Re: Redefine/Override methods?
 
Quote:

Originally Posted by YamiKaitou (Post 1065198)
Correct. But, if you return PLUGIN_HANDLED in foo.amxx, admincmd.amxx won't get called

Thanks a lot. Useful information


All times are GMT -4. The time now is 07:17.

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