Raised This Month: $ Target: $400
 0% 

register_event conditions


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-28-2014 , 20:50   Re: register_event conditions
Reply With Quote #2

Combining multiple not statements for the same parameter like that does not work. How this functions internally is that all conditions for a specific parameter are connected with or and all conditions for distinct parameters are connected with and.

In plugin pseudo-code it roughly works like this:
Code:
// Walk through all parameters of the current register_event forward for (new param = 0; param < paramc; ++param) {    new execute = 0;    new condc = get_condc(param);    /* Check each condition for the current parameter. If any one of them    applies, set the execute flag - effectively making this an *or* connection */    for (new cond = 0; cond < condc; ++cond) {       if (match_cond(param, cond))          execute = 1;    }    /* If the current parameter has any conditions, but none of them match    we exit out - so while the conditions for the current parameter are connected    with or, conditions across different parameters are connected with *and* */    if (condc > 0 && !execute)       return; } fire_forward();

Going even simpler, your first register_event basically causes this to happen internally:

Code:
if (!equal(param4, "usp") || !equal(param4, "elites")) {    // do stuff }

This will always be true, since parameter 4 will either not equal "usp" or not equal "elites" - it can't be both. The function will be executed for all weapons. The second version will result in logic equivalent to this:

Code:
if (equal(param4, "usp") || equal(param4, "elites")) {    // do stuff }

This will obviously trigger only if parameter 4 either equals "usp" or "elites" - exactly what you expect and what your tests show.

To achieve what you want you need to use two separate register_event calls. You can have them both call the same function without issues.

Great question btw
__________________
In Flames we trust!

Last edited by Nextra; 10-29-2014 at 08:12.
Nextra is offline
 



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 17:40.


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