alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
496 stars 200 forks source link

[FEATURE REQUEST] New native: register_forward2 #973

Open ShadowsAdi opened 3 years ago

ShadowsAdi commented 3 years ago

New native: register_forward2:

Same as register_event function, would allow to receive the forward only when conditions match.

Function would look like : native register_forward2(_forwardType, const function[], _post, const cond[]="", any:...);

Would allow to do such things :

    register_forward2(FM_SetClientKeyValue, "OnSetClientKeyValue_Name", 0, "2=model", "3=gign");
    register_forward2(FM_SetModel, "OnSetModel_w_Post", 1, "2&models/w_");
    register_forward2(FM_EmitSound, "OnEmitSound_knife", 0, "3&weapons/knife");

Extracted from here: https://bugs.alliedmods.net/show_bug.cgi?id=5789

dvander commented 3 years ago

This strikes me as a lot of work for very little benefit. It's a ton of code to write in the core, including a parser and evaluator for a domain-specific sublanguage. These kinds of conditions, stuffed into strings, also tend to be difficult to debug and maintain in scripts. There's minimal performance benefit. It also doesn't save you much work, since you can do the same filtering in the forward itself, with much greater flexibility and the same mount of typing.

afwn90cj93201nixr2e1re commented 3 years ago

I already don't like the way register_event/register_message/register_touch implemented.