mrewok 47 Posted January 27, 2022 Hello again my question is the following how can i retrieve or attribute an index to a "firedNear" EH an most of all how does the removeEventHandler work? how do i can remove the EH if my anim reach 0 value in this case? Here is the EH script (i can provide More if needed): Spoiler /* Ewk_Boomerang_Eh.sqf Author(s): MrEwok Description: This Apply FiredNearEH for Boomerang detection. Note : None. FilePath: \EWK_Boomerang_System\Scripts\Ewk_Boomerang_Eh.sqf */ ///////////////////////////////////////////For Boomerang System/////////////////////////////////////// /* this addEventHandler ["FiredNear", { params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode" , "_ammo", "_gunner"]; }]; */ DetectMain = false; publicVariable "DetectMain"; Detect1 = false; publicVariable "Detect1"; Detect2 = false; publicVariable "Detect2"; Detect3 = false; publicVariable "Detect3"; Detect4 = false; publicVariable "Detect4"; Detect5 = false; publicVariable "Detect5"; Detect6 = false; publicVariable "Detect6"; Detect7 = false; publicVariable "Detect7"; Detect8 = false; publicVariable "Detect8"; Detect9 = false; publicVariable "Detect9"; Detect10 = false; publicVariable "Detect10"; Detect11 = false; publicVariable "Detect11"; Detect12 = false; publicVariable "Detect12"; vclBoomerang = _this select 0; publicVariable "vclBoomerang"; while {vclBoomerang animationphase "SYS_boomerang" >= 0.5} do { DetectMain = true; if (vclBoomerang animationphase "SYS_boomerang" <= 0.5) exitWith {vclBoomerang execVM "\EWK_Boomerang_System\Scripts\Ewk_Boomerang_Loop.sqf";DetectMain = false;}; }; if (DetectMain) then { //if (vclBoomerang animationphase "hide_CrewDuke" <= 0.5) exitWith {[vclBoomerang] execVM "\EWK_M1151\HmmwvAdds\scripts\CrewDukeCheck.sqf";}; vclBoomerang addEventHandler ["FiredNear", { _this spawn { params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode" , "_ammo", "_gunner"]; if (_unit == _firer) exitWith { hintSilent ""; }; hintSilent ""; if (_distance < 100) then { { _relDir = _unit getRelDir _firer; if (_relDir > (_x select 0) && _relDir < (_x select 1)) then { XGvar = _x; publicVariable "XGvar"; sleep 0.5; //systemChat format["Shooter is at %1 from the Vehicle",(_x select 2)]; DetectMain = true; publicVariable "DetectMain"; _case = {}; if ((_x select 2) isEqualTo "12 oclock") then {_case = 1}; if ((_x select 2) isEqualTo "1 oclock") then {_case = 2}; if ((_x select 2) isEqualTo "2 oclock") then {_case = 3}; if ((_x select 2) isEqualTo "3 oclock") then {_case = 4}; if ((_x select 2) isEqualTo "4 oclock") then {_case = 5}; if ((_x select 2) isEqualTo "5 oclock") then {_case = 6}; if ((_x select 2) isEqualTo "6 oclock") then {_case = 7}; if ((_x select 2) isEqualTo "7 oclock") then {_case = 8}; if ((_x select 2) isEqualTo "8 oclock") then {_case = 9}; if ((_x select 2) isEqualTo "9 oclock") then {_case = 10}; if ((_x select 2) isEqualTo "10 oclock") then {_case = 11}; if ((_x select 2) isEqualTo "11 oclock") then {_case = 12}; ///////////// Those are parsed as they display variable and the value is true wich mean they are changed ///////////// switch (_case) do { case 1: { Detect1 = true; publicVariable "Detect1"; //systemChat "Detect1"; //systemChat str Detect1; }; case 2: { Detect2 = true; publicVariable "Detect2"; //systemChat "Detect2"; //systemChat str Detect2; }; case 3: { Detect3 = true; publicVariable "Detect3"; //systemChat "Detect3"; //systemChat str Detect3; }; case 4: { Detect4 = true; publicVariable "Detect4"; //systemChat "Detect4"; //systemChat str Detect4; }; case 5: { Detect5 = true; publicVariable "Detect5"; //systemChat "Detect5"; //systemChat str Detect5; }; case 6: { Detect6 = true; publicVariable "Detect6"; //systemChat "Detect6"; //systemChat str Detect6; }; case 7: { Detect7 = true; publicVariable "Detect7"; //systemChat "Detect7"; //systemChat str Detect7; }; case 8: { Detect8 = true; publicVariable "Detect8"; //systemChat "Detect8"; //systemChat str Detect8; }; case 9: { Detect9 = true; publicVariable "Detect9"; //systemChat "Detect9"; //systemChat str Detect9; }; case 10: { Detect10 = true; publicVariable "Detect10"; //systemChat "Detect10"; //systemChat str Detect10; }; case 11: { Detect11 = true; publicVariable "Detect11"; //systemChat "Detect11"; //systemChat str Detect11; }; case 12: { Detect12 = true; publicVariable "Detect12"; //systemChat "Detect12"; //systemChat str Detect12; }; }; if ((_x select 2) isEqualTo "12 oclock") then {vclBoomerang animate ["Led12_Hide", 1];vclBoomerang animate ["Ecran12_Hide", 1]; Sleep 1; vclBoomerang animate ["Led12_Hide", 0];vclBoomerang animate ["Ecran12_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "1 oclock") then {vclBoomerang animate ["Led1_Hide", 1];vclBoomerang animate ["Ecran1_Hide", 1]; Sleep 1;vclBoomerang animate ["Led1_Hide", 0];vclBoomerang animate ["Ecran1_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "2 oclock") then {vclBoomerang animate ["Led2_Hide", 1];vclBoomerang animate ["Ecran2_Hide", 1]; Sleep 1;vclBoomerang animate ["Led2_Hide", 0];vclBoomerang animate ["Ecran2_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "3 oclock") then {vclBoomerang animate ["Led3_Hide", 1];vclBoomerang animate ["Ecran3_Hide", 1]; Sleep 1;vclBoomerang animate ["Led3_Hide", 0];vclBoomerang animate ["Ecran3_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "4 oclock") then {vclBoomerang animate ["Led4_Hide", 1];vclBoomerang animate ["Ecran4_Hide", 1]; Sleep 1;vclBoomerang animate ["Led4_Hide", 0];vclBoomerang animate ["Ecran4_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "5 oclock") then {vclBoomerang animate ["Led5_Hide", 1];vclBoomerang animate ["Ecran5_Hide", 1]; Sleep 1;vclBoomerang animate ["Led5_Hide", 0];vclBoomerang animate ["Ecran5_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "6 oclock") then {vclBoomerang animate ["Led6_Hide", 1];vclBoomerang animate ["Ecran6_Hide", 1]; Sleep 1;vclBoomerang animate ["Led6_Hide", 0];vclBoomerang animate ["Ecran6_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "7 oclock") then {vclBoomerang animate ["Led7_Hide", 1];vclBoomerang animate ["Ecran7_Hide", 1]; Sleep 1;vclBoomerang animate ["Led7_Hide", 0];vclBoomerang animate ["Ecran7_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "8 oclock") then {vclBoomerang animate ["Led8_Hide", 1];vclBoomerang animate ["Ecran8_Hide", 1]; Sleep 1;vclBoomerang animate ["Led8_Hide", 0];vclBoomerang animate ["Ecran8_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "9 oclock") then {vclBoomerang animate ["Led9_Hide", 1];vclBoomerang animate ["Ecran9_Hide", 1]; Sleep 1;vclBoomerang animate ["Led9_Hide", 0];vclBoomerang animate ["Ecran9_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "10 oclock") then {vclBoomerang animate ["Led10_Hide", 1];vclBoomerang animate ["Ecran10_Hide", 1]; Sleep 1;vclBoomerang animate ["Led10_Hide", 0];vclBoomerang animate ["Ecran10_Hide", 0];systemChat str (_x select 2);}; if ((_x select 2) isEqualTo "11 oclock") then {vclBoomerang animate ["Led11_Hide", 1];vclBoomerang animate ["Ecran11_Hide", 1]; Sleep 1; vclBoomerang animate ["Led11_Hide", 0];vclBoomerang animate ["Ecran11_Hide", 0];systemChat str (_x select 2);}; systemChat str _relDir; //_Select2 = _x select 2; //systemChat str (_x select 2); }; } forEach [ [0, 15, "12 oclock"], [15, 45, "1 oclock"], [45, 75, "2 oclock"], [75, 105, "3 oclock"], [105, 135, "4 oclock"], [135, 165, "5 oclock"], [165, 195, "6 oclock"], [195, 225, "7 oclock"], [225, 255, "8 oclock"], [255, 285, "9 oclock"], [285, 315, "10 oclock"], [315, 345, "11 oclock"], [345, 360, "12 oclock"] ]; }; }; }]; }; The problem is i can't figure how to remove the EH when the anim reach back 0 value wich mean is hided and add it back when the anim reach back 1 value wich mean is visible... Share this post Link to post Share on other sites
Harzach 2516 Posted January 27, 2022 From the Biki: Quote Since Arma 3 v1.64 the Event Handler index is available as _thisEventHandler during Event Handler code execution and can be used to easily remove the Event Handler: player addEventHandler ["FiredNear", { systemChat "This Event Handler is now removing itself!"; player removeEventHandler ["FiredNear", _thisEventHandler]; }]; So I would guess that, wherever in your EH's code would be prudent, something along the lines of: if (<yourValue == 0>) then { _unit removeEventHandler ["FiredNear", _thisEventHandler]; }; 2 Share this post Link to post Share on other sites
mrewok 47 Posted January 28, 2022 Well i've tried to add this in my EH code just before the end but the problem is that it's exit after one Event (one shot in this case) and doesn't start back. if (vclBoomerang animationphase "SYS_boomerang" <= 0.5) then { vclBoomerang removeEventHandler ["FiredNear", _thisEventHandler]; }; Share this post Link to post Share on other sites
mrewok 47 Posted January 29, 2022 I was thinking i could add an ID to my EH remove it and re add it after but i have no clue on how it work, based on the biki it seems ID is applied for each EH starting from 0 but how does this apply to FiredNear? Each shot , each frame, or only once when EH is Applied? Thanks! Share this post Link to post Share on other sites
mrewok 47 Posted February 2, 2022 Finally managed to make it work. Share this post Link to post Share on other sites