Raised This Month: $ Target: $400
 0% 

return PLUGIN_*


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TaRgEt-PrAcTiCe21
Junior Member
Join Date: Feb 2005
Old 02-21-2005 , 04:02   return PLUGIN_*
Reply With Quote #1

Ok, i'm sort of new to writing small. I understand it for the most part except or the return PLUGIN_ command. I know when to use them and stuff it's just that i'm a little slow in the head and I need someone to explain the difference between PLUGIN_HANDLED and PLUGIN_CONTINUE. If you could elaborate this for me i would love you forever.
TaRgEt-PrAcTiCe21 is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-21-2005 , 10:09  
Reply With Quote #2

PLUGIN_CONTINUE and PLUGIN_HANDLED are returned from AMXX Forwards and Registered Commands that tell AMXX what to do after your function has been executed.

If your function returns PLUGIN_CONTINUE you are telling AMXX to continue processing the same function in other plugins. An example would be

public plugin_cfg() { return PLUGIN_CONTINUE }

plugin_cfg() is an AMXX Forward function, and by returning PLUGIN_CONTINUE you are telling AMXX to continue processing the plugin_cfg() function of other plugins found in your plugins.ini listed *after* your plugin..

If you returned PLUGIN_HANDLED from plugin_cfg() then any other plugins that are listed below yours in plugins.ini which use the Forward plugin_cfg() will not be allowed to execute their respective plugin_cfg() function..

You should almost always return PLUGIN_CONTINUE from AMXX Forwards, however, there are logical exceptions...

Now, with Registered Commands, you get to "Invent" the name of the command and the name of the function that it calls, an example would be:

register_clcmd( "amx_stuff", "DoStuff" )

'amx_stuff' is the name of the command that we are inventing, and the respective Small C Function which we create we called 'DoStuff'..

Now, since probably no other AMXX plugin will have the same command 'amx_stuff' we don't need to worry about other plugins calling our invented command, so we are free to (and encouraged to) return PLUGIN_HANDLED which tells AMXX that after executing our 'DoStuff' command AMXX is done, and does not need to look for the same function from other plugins.

Basically, PLUGIN_CONTINUE tells AMXX to continue processing equivalent functions in other plugins, whereas PLUGIN_HANDLED tells AMXX the exact opposite, to stop proccessing equivalent functions in other plugins..

I hope that helps a bit..
xeroblood is offline
Send a message via MSN to xeroblood
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-21-2005 , 11:08  
Reply With Quote #3

plugin_cfg is a bad example. Here is a list of core forwards and what they do with your return value:

plugin_init - return value ignored
client_command - What xeroblood described
client_connect - return value ignored
client_disconnect - return value ignored
client_infochanged - return value ignored
client_putinserver - return value ignored
plugin_cfg - return value ignored
plugin_precache - return value ignored
plugin_log - What xeroblood described
plugin_end - return value ignored
inconsistent_file - What xeroblood described
client_authorized - return value ignored
server_changelevel - What xeroblood described
__________________
hello, i am pm
PM is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-21-2005 , 13:47  
Reply With Quote #4

Ooooh.. thx for clearing that up PM!!
I thought they were all handled the same way internally with regards to the return value..

Thx for that list too, now I know which forwards I can omit the return value of completely!! I'm surprised to see that so many are actually ignored..

xeroblood is offline
Send a message via MSN to xeroblood
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-21-2005 , 14:28  
Reply With Quote #5

Quote:
Originally Posted by xeroblood
Ooooh.. thx for clearing that up PM!!
I thought they were all handled the same way internally with regards to the return value..

Thx for that list too, now I know which forwards I can omit the return value of completely!! I'm surprised to see that so many are actually ignored..

It would be pretty bad if a plugin decided to block plugin_init ^^

You can search meta_api for "plugin_init" (in quotes), there you will have ET_IGNORE which means the return value is ignored

ET_STOP means the "normal PLUGIN_HANDLED system" (basically, nonzero value -> stop executing plugins and return the value that the plugin returned)

ET_STOP2 is like ET_STOP but support PLUGIN_HANDLED_MAIN (-> stop execution on a PLUGIN_HANDLED, continue otherwise, returns the highest return value)

ET_CONTINUE means ignore return value and return the highest one (useful for one-plugin-only forwards).

More on this in CForward.h
__________________
hello, i am pm
PM is offline
TaRgEt-PrAcTiCe21
Junior Member
Join Date: Feb 2005
Old 02-21-2005 , 15:20  
Reply With Quote #6

Wow, thanks you guys, this is going to help my tons. I'll just have to experiment a little to see what i'm able to do with my plugins.
TaRgEt-PrAcTiCe21 is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-21-2005 , 16:46  
Reply With Quote #7

PM so if 2 plugins catch the command hegren and one does return PLUGIN_HANDLED, the other won't be able to see it?
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-21-2005 , 18:05  
Reply With Quote #8

I know you're asking PM, but I think you're right anyway..

if pluginA hooks hegren using client_command, and returns PLUGIN_HANDLED, then pluginB wont be able to hook hegren using client_command, but only if pluginA is listed before pluginB in plugins.ini

If pluginA were listed very last in plugins.ini then it wouldn't affect the other plugins...

Is this correct?
xeroblood is offline
Send a message via MSN to xeroblood
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-22-2005 , 08:26  
Reply With Quote #9

that would suck, b/c war3ft is always like the last plugin loaded LOL, luckily I don't think any default plugins return PLUGIN_HANDLED on hegren
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
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 23:44.


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