AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A little explanation plz, and maby a short example of use :) (https://forums.alliedmods.net/showthread.php?t=28325)

L0neW0lf 05-12-2006 17:08

A little explanation plz, and maby a short example of use :)
 
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

Xanimos 05-12-2006 17:53

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).


L0neW0lf 05-12-2006 19:23

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 ?

Xanimos 05-12-2006 19:40

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'.

VEN 05-15-2006 08:46

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.

Xanimos 05-15-2006 08:50

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.


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

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