Fixing Plugin Confliction
I am running the teo following plugins on my server. The first one works and the second one doesnt. I suspect that there is some confliction between them because they are basically the same code. One grants clients a free gun once per map and one grants users hp or ap once per map. Can someone help me find the confliction and fix it?
Code:
Code:
Thanks, MOBOB |
I dont think they conflict, because the clcmds are different
|
I'm just curious.
What happens when you use "return PLUGIN_CONTINUE" instead of "return PLUGIN_HANDLED"? |
Ah, no, well.
Both plugins register a client command ("give" and "freegun") and map it to their cmd_weapon public function. Yes, there are two of them, but they don't conflict because each one is in another plugin and they are mapped to two different clcmds. What WOULD conflict is if both plugins used the same command name (ie. the first parameter of register_clcmd was the same). Well at least they shouldn't conflict, I just woke up and I'm confused. Anyway, let's go on. What would happen if you returned PLUGIN_CONTINUE ? Let's go from the beginning (talking about client commands). Here is an example: Plugin A registers client command hello Plugin B registers client command hello (later than plugin A) Okay, the simplest case is that plugin A returns PLUGIN_HANDLED from its handler. plugin B's handler won't execute at all. The next case is that plugin A returns PLUGIN_CONTINUE. In this case, plugin B's handler will be executed. If plugin B's handler now returns PLUGIN_CONTINUE as well, you will get the "command not found" message in your console. If it returns PLUGIN_HANDLED, there will be no such message. BUT!!!!!!!!!! THERE'S ONE MORE CASE!!!!!!! Plugin A can return PLUGIN_HANDLED_MAIN. Then plugin B's handler gets called. However, no matter what plugin B's handler returns - the result of the "whole operation" will be PLUGIN_HANDLED (because plugin A said it would be) - which means that you won't get that "command not found" message thing. IIRC it's a bit different with server commands, because with client commands, server plugins act like filters. ie. the engine says: DUDE, LOOK, A CLIENT COMMAND ARRIVED and then each plugin can say "Yup, I handled it, it's ok" or "Oh noes LOL!!!!! NOES!!! I don't want this command". AMXX, being one of the server plugins, has two ways of performing this filtering action: 1) register_clcmd, which we've just talked about and 2) the client_command forward function, which works just like metamod's ClientCommand forward. Okay, so what's the matter with server commands? Well, here, the engine does the filtering. That is, you say, "I register command gaben" and then the engine always knows that command gaben is registered by you, so it only calls your handler. You can't decide "I don't know this server command" once you've registered it (unlike with client commands). However, you can decide whether subsequent handlers of the same command will be executed by returning either PLUGIN_CONTINUE or PLUGIN_HANDLED. Note that I'm not completly sure about the server commands thing. |
Wouldn't you want to do this
Code:
instead of this Code:
If your using true and false you want to tell it what it's looking for. Correct me if I'm wrong. |
You probably mean
Code:
(note that the == true part is inside the parenthesis and that you have to use the == operator for comparision (instead of = which is assignment)). However, in this case, it has the same effect. false is 0 and true is 1, and Code:
This means that Code:
Code:
Code:
If you are only using true/false (as in this example), != false is basically the same as checking for == true. |
Re: Fixing Plugin Confliction
Now ... that is all interesting, BUT:
What more can happen if i use PLUGIN_CONTINUE everywhere?!? Just that stupid error-message? |
Re: Fixing Plugin Confliction
If you use PLUGIN_CONTINUE, then for commands that are chat messages such as /me will be shown in chat.
Also, more than one plugin can register the same command as long as PLUGIN_HANDLED is never returned. By the way, don't revive a 3-year-old topic again. |
Re: Fixing Plugin Confliction
Quote:
It contains exactly the discussion with information that seem to help :) I can start a new one, but what is the difference? On topic: Now, PLUGIN_CONTINUE is the default, so only in some cases that should be changed to PLUGIN_HANDLED* - if required. So far, i just cannot find a situation where changing this to PLUGIN_HANDLED* is required! For what reason? If the only effect of using PLUGIN_CONTINUE everywhere, is the message "command not found", it seems, i could just use PLUGIN_CONTINUE everywhere. No? Yes? |
Re: Fixing Plugin Confliction
It depends on the context you use the PLUGIN_HANDLED/CONTINUE
HANDLED means that you break the operation that is hooked, but not all the time! CONTINUE means that you didn't do any modifications so the action will continue! |
| All times are GMT -4. The time now is 16:12. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.