fildred13 10 Posted February 22, 2015 I have the following in my init.sqf in order to add a fired event handler for the player: player addEventHandler["fired", {if !(this call "fil_scripts\suppressorCheck.sqf") then {hint "Unsuppressed shot detected"}}]; The code successfully detects the fired event, as the following code works just fine: player addEventHandler["fired", {hint "weapon fired"}]; My problem is that I'm not sure how to call my suppressorCheck.sqf correctly. I am trying to pass the array of information of the "fired" event to suppressorCheck.sqf, and then that will return true if an unsuppressed weapon was fired. Frankly, I think my only problem is in calling the script from the event handler, but in case people are curious, here is the suppressorCheck.sqf: private ["_suppressor"]; _weaponFired = _this select 1; _weaponItems = weaponsItems player; _suppressor = false; { if ((_weaponFired == _x select 0) && !((_x select 1) == "")) then { _suppressor = true; }; } forEach _weaponItems; /* if (_suppressor) then { player sideChat "Yes, I had a silencer"; } else { player sideChat "No, I didn't"; }; */ _suppressor Share this post Link to post Share on other sites
CoA|Saint 5 Posted February 22, 2015 maybe this can be helpful? : http://forums.bistudio.com/showthread.php?169796-How-to-detect-if-player-have-a-silencer-on-his-weapon Share this post Link to post Share on other sites
fight9 14 Posted February 22, 2015 (edited) // compile the function fil_fnc_suppressorCheck = compile preprocessFileLineNumbers "fil_scripts\suppressorCheck.sqf"; // add EH player addEventHandler["fired", {if !(this call fil_fnc_suppressorCheck) then {hint "Unsuppressed shot detected"}}]; or // place the code right in the EH player addEventHandler["fired",{ _weaponFired = _this select 1; _weaponItems = weaponsItems player; _suppressor = false; { if ((_weaponFired == _x select 0) && !((_x select 1) == "")) then { _suppressor = true; }; } forEach _weaponItems; if !(_suppressor) then {hint "Unsuppressed shot detected"}; }]; dont // will recompile on every shot... no need for that player addEventHandler["fired", {if !(this call compile preprocessFile "fil_scripts\suppressorCheck.sqf") then {hint "Unsuppressed shot detected"}}]; Edited February 22, 2015 by Fight9 Share this post Link to post Share on other sites
killzone_kid 1326 Posted February 22, 2015 You can find a simpler and faster silencer detection on biki https://community.bistudio.com/wiki/weaponAccessories Share this post Link to post Share on other sites
CoA|Saint 5 Posted February 22, 2015 You can find a simpler and faster silencer detection on biki https://community.bistudio.com/wiki/weaponAccessories very helpful! thank you K_K :) Share this post Link to post Share on other sites