This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Redefine/Override methods?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rjckE
Junior Member
Join Date: Mar 2009
Old 01-23-2010 , 22:20   Redefine/Override methods?
Reply With Quote #1

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
__________________

Last edited by rjckE; 01-23-2010 at 22:21. Reason: indentation, sorry
rjckE is offline
Send a message via MSN to rjckE
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-23-2010 , 22:26   Re: Redefine/Override methods?
Reply With Quote #2

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).
__________________
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
rjckE
Junior Member
Join Date: Mar 2009
Old 01-23-2010 , 22:30   Re: Redefine/Override methods?
Reply With Quote #3

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!
__________________
rjckE is offline
Send a message via MSN to rjckE
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-23-2010 , 22:38   Re: Redefine/Override methods?
Reply With Quote #4

Quote:
Originally Posted by rjckE View Post
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
__________________
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
rjckE
Junior Member
Join Date: Mar 2009
Old 01-23-2010 , 22:47   Re: Redefine/Override methods?
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
Correct. But, if you return PLUGIN_HANDLED in foo.amxx, admincmd.amxx won't get called
Thanks a lot. Useful information
__________________
rjckE is offline
Send a message via MSN to rjckE
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 22:39.


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