Raised This Month: $ Target: $400
 0% 

A little explanation plz, and maby a short example of use :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 17:08   A little explanation plz, and maby a short example of use :)
Reply With Quote #1

I have seen theese constants in other plugins, but i miss to se their general purpose.....so could someone plz help me out with a little explanation on them.....

PLUGIN_CONTINUE
PLUGIN_HANDLED
PLUGIN_HANDLED_MAIN

Thanks in advance

/Lone Wolf
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-12-2006 , 17:53  
Reply With Quote #2

Quote:
Originally Posted by AMXX WIKI
Also, note PLUGIN_HANDLED. There are two main return values you should concern yourself with. PLUGIN_CONTINUE generally means "continue with normal operation", and PLUGIN_HANDLED means "block further operation". The differences are subtle but important. For example, when binding a command, you should never return PLUGIN_CONTINUE. But if you return PLUGIN_HANDLED while binding to the "say" command, it will block the player's text from ever appearing. You must be careful with which you choose in certain situations. However, most things are unaffected (such as tasks, events, and other things you will run into later on).
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
L0neW0lf
Member
Join Date: Mar 2006
Location: Denmark
Old 05-12-2006 , 19:23  
Reply With Quote #3

Thanks that help a bit but still a little confused......
Ill try an eksample:

Code:
public action { If var = 1 {    //Code    return PLUGIN_HANDLED; //This stops the plugin from continuing    } else if var = 2 {    //Code    return PLUGIN_CONTINUE; //stops the if, but still runs server_cmd(option1,option2)    } else {    //Code    } server_cmd(option1,option2) }


Is that understood the right way ?
L0neW0lf is offline
Send a message via ICQ to L0neW0lf Send a message via MSN to L0neW0lf Send a message via Skype™ to L0neW0lf
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-12-2006 , 19:40  
Reply With Quote #4

No.

When you use return it will exit the whole function.
Its just if you use return PLUGIN_HANDLED in register_event() no other plugin below yours will be able to use the event but if you use return PLUGIN_CONTINUE it will still allow all other plugins to use the event.

To exit an if statement early it is 'exit' . To exit a switch() early it is 'break' to exit a loop, could be a for loop or while loop, you use 'exit'. To stop the rest of the code for that iteration of the loop you use 'continue'.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
VEN
Veteran Member
Join Date: Jan 2005
Old 05-15-2006 , 08:46  
Reply With Quote #5

A little correction: "message", not "event". Event can't be blocked because it's already occured. While message which triggers an event can be blocked.
VEN is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-15-2006 , 08:50  
Reply With Quote #6

Quote:
Originally Posted by VEN
A little correction: "message", not "event". Event can't be blocked because it's already occured. While message which triggers an event can be blocked.
Yea thats what I meant. I was in a rush to get out when I wrote that.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply


Thread Tools
Display Modes

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 05:14.


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