logan83 11 Posted December 20, 2024 Hi guys! I'm not skilled in scripting and I have messed trying to make a Alert System based in some codes that i have in my old Arma 3 folder... the idea is to detect all shooting weapons, granadelaunchers, granades, etc... except the silenced shoots. Well Im in the way but its too dirty and im stuck. I put in my Init.sqf this line to add all units in game the event handler: {if((side _x in [blufor,opfor]) && (local _x)) then {_x addEventHandler ["fired", {if ((_this call fnc_suppressorCheck) or (configname (inheritsFrom (configFile >> "cfgWeapons" >> "throw" >>(_this select 2) )) isEqualTo "ThrowMuzzle")) then {FusShot = true; publicVariable "FusShot";HINT "UNSUPPRESSED!"};}];};} foreach allunits; and this is the fnC_SupressorCheck Function: fnc_suppressorCheck = { private ["_suppressor"]; _weaponFired = _this select 1; _Soldado = _this select 0; _weaponItems = weaponsItems _Soldado; _suppressor = False; { if ((_weaponFired == _x select 0) && ((_x select 1) == "")) then { _suppressor = true; }; } forEach _weaponItems; _suppressor }; if(true) exitWith{}; This works, detect the like handgrenades, chemlights, smoke grenades, RPGS , rifle shoots (but correctly ignores the supressed), pistol shoots (but correctly ignores the supressed), but, don't detect, grenade launchers, and satchels.... Any Help whit that?? Thank you So much!! Share this post Link to post Share on other sites
pierremgi 4906 Posted December 21, 2024 All in one code: if isServer then {FusShot = FALSE; publicVariable "FusShot"}; { _x addEventHandler ["firedMan",{ params ["_unit", "_weapon","_muzzle","","_ammo","_mag","_proj"]; systemChat str [_unit,_muzzle,_ammo,_mag,_proj]; call { if (_weapon isEqualTo "Throw" && {!("grenade" in toLowerANSI _ammo)}) exitWith {}; if (_weapon isEqualTo "Put") exitWith {_proj addEventHandler ["explode",{FusShot = TRUE; publicVariable "FusShot"}]}; private _wpIts = weaponsItems _unit; private _idx = _wpIts findIf {_x #0 isEqualTo _muzzle}; if (_wpIts #_idx#1 isEqualTo "") exitWith {FusShot = TRUE; publicVariable "FusShot"}; }; }]; } foreach (allunits select {side _x in [EAST,WEST]}); First line is for FusShot initialization, once for all I'm using firedMan instead of fired EH (see BIKI) Intended behavior: Doesn't trigger for smoke , chemlight and IR grenade, but triggers for hand explo grenade Doesn't trigger on putting charges but triggers when it explodes This EH must be added on spawned units if necessary. 2 Share this post Link to post Share on other sites
logan83 11 Posted December 21, 2024 oh! it's so clean and fancy! thanks for the work, i was tested right now, it work like a charm but not detect the satchels or put explosives, maybe is cause i have load ACE mod, I test it later without ACE, thank you so much Buddy! Share this post Link to post Share on other sites
pierremgi 4906 Posted December 22, 2024 9 hours ago, logan83 said: oh! it's so clean and fancy! thanks for the work, i was tested right now, it work like a charm but not detect the satchels or put explosives, maybe is cause i have load ACE mod, I test it later without ACE, thank you so much Buddy! I'm not using ACE because it alters too much Arma vanilla. My code works as the "firedMan" EH fires when the player "puts" a charge/mine.. which is the case in vanilla. In this code, once this EH is fired, the "put" (as weapon) triggers another EH (explode) on projectile. That works for Vanilla and all DLCs mods which don't garble "put" action or explosion. I can't say what occurs in specific cases. 1 Share this post Link to post Share on other sites
logan83 11 Posted December 22, 2024 Thats correct, running smooth in Vanilla, It was cause i have loaded ACE when i try it. Great work I appreciate it very much! Thank You! Share this post Link to post Share on other sites