_-xXShArK_OGXx-_ 6 Posted October 15, 2021 Hi all. Could you help me with the right format for finding UXO's near the player?? i like to find these in a 10m radius of the player: uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3" ]; I have tryed: Nuxos = position player nearObjects [uxoType,10]; ->> no luck nObject = position player nearObjects [(iskindOf uxoType),500]; ->> no luck nObject = getPos player nearestObject uxoType; ->> no luck and a bunch of other combos, but I'm not sure of the format. i also noticed that there are other names for the objects like: "rhs_uxo_ptab25m_2" ->> "rhs_ammo_uxo_ptab25m_2" and "rhs_uxo_ao1_2" ->> "rhs_ammo_uxo_ao1_2" if I use this in Debug Console I see them and myself nObject = player nearObjects 10; hint str nObject; please help. thx. Share this post Link to post Share on other sites
soldierXXXX 97 Posted October 16, 2021 Hi. You tried to assign array instead of string so the command did nothing. Try it like this: Nuxos = position player nearObjects ["mineBase",10]; I assigned parent class, so you don´t have to look for every type of UXOs in your array and it automaticly finds all mines in player´s 10m area. If you wish to list only UXOs and not other mines, you could do it like this: uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3" ]; private _Nuxos = position player nearObjects ["mineBase",10]; ArrUXOs = []; { if (typeOf _x in uxoType) then {ArrUXOs pushBack _x}; } forEach _Nuxos; //ArrUXOs now contains only objects near player that you defined in your array uxoType. But there is one important notice. If you placed your UXOs from editor, they change into diferent type. You can find these types in cfgAmmo. That is, if you place UXO, which Editor shows as type "BombCluster_01_UXO4_F", then when you hit play, it changes to "BombCluster_01_UXO4_Ammo_F" and will be ignored in the code above. you can test it with: //insert this code into debug console (or your script) and in editor make a line of UXOs you want to have in your mission each only once (to not deal with duplicates in result array) private _Nuxos = (position player nearObjects ["mineBase",50]) apply {typeOf _x}; systemChat str _Nuxos; copyToClipboard str _Nuxos;//insert result into your uxoType array (remove brackets if you expanding original array) I hope these informations are usefull for you. 🙂 1 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 16, 2021 3 hours ago, soldierXXXX said: Hi. You tried to assign array instead of string so the command did nothing. Try it like this: Nuxos = position player nearObjects ["mineBase",10]; I assigned parent class, so you don´t have to look for every type of UXOs in your array and it automaticly finds all mines in player´s 10m area. If you wish to list only UXOs and not other mines, you could do it like this: uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3" ]; private _Nuxos = position player nearObjects ["mineBase",10]; ArrUXOs = []; { if (typeOf _x in uxoType) then {ArrUXOs pushBack _x}; } forEach _Nuxos; //ArrUXOs now contains only objects near player that you defined in your array uxoType. But there is one important notice. If you placed your UXOs from editor, they change into diferent type. You can find these types in cfgAmmo. That is, if you place UXO, which Editor shows as type "BombCluster_01_UXO4_F", then when you hit play, it changes to "BombCluster_01_UXO4_Ammo_F" and will be ignored in the code above. you can test it with: //insert this code into debug console (or your script) and in editor make a line of UXOs you want to have in your mission each only once (to not deal with duplicates in result array) private _Nuxos = (position player nearObjects ["mineBase",50]) apply {typeOf _x}; systemChat str _Nuxos; copyToClipboard str _Nuxos;//insert result into your uxoType array (remove brackets if you expanding original array) I hope these informations are usefull for you. 🙂 thx Champ, it seems like something i can use, ill give it a shot and report back here 🙂 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 17, 2021 Your code works like a charm, but I still can't get it to work when put it in with the script. fnc--->> (I tried to fill in your code) EODS_MDET_fnc_getNearestUxo = { private ["_found", "_nearestUxo", "_DetectionPoint", "_allUxo", "_Uxo", "_distance",_uxoType]; _uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3","rhs_ammo_uxo_blu97","BombCluster_03_UXO1_Ammo_F", "BombCluster_02_UXO1_Ammo_F","BombCluster_01_UXO1_Ammo_F","BombCluster_03_UXO4_Ammo_F","BombCluster_02_UXO4_Ammo_F", "BombCluster_01_UXO4_Ammo_F","BombCluster_03_UXO2_Ammo_F","BombCluster_02_UXO2_Ammo_F","BombCluster_01_UXO2_Ammo_F", "BombCluster_03_UXO3_Ammo_F","BombCluster_02_UXO3_Ammo_F","BombCluster_01_UXO3_Ammo_F","rhs_ammo_uxo_ao1_1","rhs_ammo_uxo_ao1_2","rhs_ammo_uxo_ao1_3", "rhs_ammo_uxo_ptab1m_1","rhs_ammo_uxo_ptab1m_2","rhs_ammo_uxo_ptab1m_3","rhs_ammo_uxo_ptab25ko_1","rhs_ammo_uxo_ptab25ko_2","rhs_ammo_uxo_ptab25ko_3", "rhs_ammo_uxo_ptab25m_1","rhs_ammo_uxo_ptab25m_2","rhs_ammo_uxo_ptab25m_3" ]; _found = false; _nearestUxo = []; _DetectionPoint = "Helper_Base_F" createVehicleLocal getPos Player; // create detection point _DetectionPoint attachto [player,[-0.4,0.8,-0.8],"granat"]; // attach point to player memorypoint "granat" , we can use "granat2" , "LeftHand" , "RightHand" and maybe "aimPoint".... _allUxo = position player nearObjects ["mineBase",10]; ArrUXOs = []; { if (typeOf _x in _uxoType) then {ArrUXOs pushBack _x}; } forEach _Nuxos; for "_i" from 0 to ((count ArrUXOs) - 1) do { _Uxo = ArrUXOs select _i; _distance = _DetectionPoint distance _Uxo; if (_distance <= EODS_MDET_var_radius) then { if ([getPos player, getDir player, EODS_MDET_var_angle, getPos _Uxo] call BIS_fnc_inAngleSector) then { if (_found) then { if ((_nearestUxo select 1) > _distance) then { _nearestUxo = [_Uxo, _distance]; }; } else { _found = true; _nearestUxo = [_Uxo, _distance]; }; }; }; }; deleteVehicle _DetectionPoint; _nearestUxo; }; Share this post Link to post Share on other sites
soldierXXXX 97 Posted October 17, 2021 I found few mistakes and fixed your code. Now it should work properly. Change the variables to fit your needs and let me know if that helped 🙂 EODS_MDET_var_radius = 10; EODS_MDET_var_angle = 90; EODS_MDET_fnc_getNearestUxo = { private ["_found", "_nearestUxo", "_DetectionPoint", "_allUxo", "_Uxo", "_distance","_uxoType"]; _uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3","rhs_ammo_uxo_blu97","BombCluster_03_UXO1_Ammo_F", "BombCluster_02_UXO1_Ammo_F","BombCluster_01_UXO1_Ammo_F","BombCluster_03_UXO4_Ammo_F","BombCluster_02_UXO4_Ammo_F", "BombCluster_01_UXO4_Ammo_F","BombCluster_03_UXO2_Ammo_F","BombCluster_02_UXO2_Ammo_F","BombCluster_01_UXO2_Ammo_F", "BombCluster_03_UXO3_Ammo_F","BombCluster_02_UXO3_Ammo_F","BombCluster_01_UXO3_Ammo_F","rhs_ammo_uxo_ao1_1","rhs_ammo_uxo_ao1_2","rhs_ammo_uxo_ao1_3", "rhs_ammo_uxo_ptab1m_1","rhs_ammo_uxo_ptab1m_2","rhs_ammo_uxo_ptab1m_3","rhs_ammo_uxo_ptab25ko_1","rhs_ammo_uxo_ptab25ko_2","rhs_ammo_uxo_ptab25ko_3", "rhs_ammo_uxo_ptab25m_1","rhs_ammo_uxo_ptab25m_2","rhs_ammo_uxo_ptab25m_3" ]; _found = false; _nearestUxo = []; _DetectionPoint = "Helper_Base_F" createVehicleLocal getPos Player; // create detection point _DetectionPoint attachto [player,[-0.4,0.8,-0.8],"granat"]; // attach point to player memorypoint "granat" , we can use "granat2" , "LeftHand" , "RightHand" and maybe "aimPoint".... _allUxo = position player nearObjects ["mineBase",10]; ArrUXOs = []; { if (typeOf _x in _uxoType) then {ArrUXOs pushBack _x}; } forEach _allUxo; for "_i" from 0 to ((count ArrUXOs) - 1) do { _Uxo = ArrUXOs select _i; _distance = _DetectionPoint distance _Uxo; if (_distance <= EODS_MDET_var_radius) then { if ([getPos player, getDir player, EODS_MDET_var_angle, getPos _Uxo] call BIS_fnc_inAngleSector) then { if (_found) then { if ((_nearestUxo select 1) > _distance) then { _nearestUxo = [_Uxo, _distance]; }; } else { _found = true; _nearestUxo = [_Uxo, _distance]; }; }; }; }; deleteVehicle _DetectionPoint; _nearestUxo; }; private _NearestUxoResult = call EODS_MDET_fnc_getNearestUxo; //debug if (_NearestUxoResult isNotEqualTo []) then { systemChat str _NearestUxoResult; private _ShowBomb = "Sign_Arrow_Cyan_F" createVehicleLocal position (_NearestUxoResult select 0);//just for debug _ShowBomb attachTo [(_NearestUxoResult select 0),[0,0,0.6]];//for some reason to show right position pointer needs to be attached detach _ShowBomb; } else { systemChat "Nothing found"; }; 1 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 17, 2021 thx. Almost working I think. if I place down a UXO in Editor within 10 m the dbug finds it and hints the Infos 🙂 if I start more than 10 meters I get a hin nothing found 🙂 but if I move closer to the UXO nothing happens other than a big Bang 😞 last part of the script, not sure if this affects the other part 🙂 EODS_MDET_fnc_playSound = { private "_percentage"; _percentage = _this / EODS_MDET_var_radius * 100; switch (true) do { case (_percentage > 80 && _percentage < 100): { playSound "MDS_1" }; case (_percentage > 60 && _percentage < 80): { playSound "MDS_2" }; case (_percentage > 40 && _percentage < 60): { playSound "MDS_3" }; case (_percentage > 20 && _percentage < 40): { playSound "MDS_4" }; case (_percentage > 10 && _percentage < 20): { playSound "MDS_5" }; case (_percentage > 0 && _percentage < 10): { playSound "MDS_6" }; }; }; //Uxo EODS_MDET_fnc_UxoInRange = { private "_distance"; _distance = _this select 1; if (EODS_MDET_var_rnd_radius) then { _distance = _distance call EODS_MDET_fnc_randomize; }; _distance call EODS_MDET_fnc_playSound; ////// MINE IS IN RANGE AND IN CORRECT ANGLE ////// //systemChat format["Explosive detected in radius: %1m", round _distance]; }; Share this post Link to post Share on other sites
soldierXXXX 97 Posted October 17, 2021 (edited) If you need constant checking do it this way: EODS_MDET_var_radius = 10; EODS_MDET_var_angle = 90; EODS_MDET_fnc_getNearestUxo = { private ["_found", "_nearestUxo", "_DetectionPoint", "_allUxo", "_Uxo", "_distance","_uxoType","_ArrUXOs"]; _uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3","rhs_ammo_uxo_blu97","BombCluster_03_UXO1_Ammo_F", "BombCluster_02_UXO1_Ammo_F","BombCluster_01_UXO1_Ammo_F","BombCluster_03_UXO4_Ammo_F","BombCluster_02_UXO4_Ammo_F", "BombCluster_01_UXO4_Ammo_F","BombCluster_03_UXO2_Ammo_F","BombCluster_02_UXO2_Ammo_F","BombCluster_01_UXO2_Ammo_F", "BombCluster_03_UXO3_Ammo_F","BombCluster_02_UXO3_Ammo_F","BombCluster_01_UXO3_Ammo_F","rhs_ammo_uxo_ao1_1","rhs_ammo_uxo_ao1_2","rhs_ammo_uxo_ao1_3", "rhs_ammo_uxo_ptab1m_1","rhs_ammo_uxo_ptab1m_2","rhs_ammo_uxo_ptab1m_3","rhs_ammo_uxo_ptab25ko_1","rhs_ammo_uxo_ptab25ko_2","rhs_ammo_uxo_ptab25ko_3", "rhs_ammo_uxo_ptab25m_1","rhs_ammo_uxo_ptab25m_2","rhs_ammo_uxo_ptab25m_3" ]; _found = false; _nearestUxo = []; _DetectionPoint = "Helper_Base_F" createVehicleLocal getPos Player; // create detection point _DetectionPoint attachto [player,[-0.4,0.8,-0.8],"granat"]; // attach point to player memorypoint "granat" , we can use "granat2" , "LeftHand" , "RightHand" and maybe "aimPoint".... _allUxo = position player nearObjects ["mineBase",EODS_MDET_var_radius]; _ArrUXOs = []; { if (typeOf _x in _uxoType) then {_ArrUXOs pushBack _x}; } forEach _allUxo; for "_i" from 0 to ((count _ArrUXOs) - 1) do { _Uxo = _ArrUXOs select _i; _distance = _DetectionPoint distance _Uxo; if (_distance <= EODS_MDET_var_radius) then { if ([getPos player, getDir player, EODS_MDET_var_angle, getPos _Uxo] call BIS_fnc_inAngleSector) then { if (_found) then { if ((_nearestUxo select 1) > _distance) then { _nearestUxo = [_Uxo, _distance]; }; } else { _found = true; _nearestUxo = [_Uxo, _distance]; }; }; }; }; deleteVehicle _DetectionPoint; _nearestUxo; }; [] spawn { scriptName "CheckForUXO_script"; CheckActive = TRUE; while {CheckActive} do { private _NearestUxoResult = call EODS_MDET_fnc_getNearestUxo; //debug if (_NearestUxoResult isNotEqualTo []) then { systemChat str _NearestUxoResult; private _ShowBomb = "Sign_Arrow_Cyan_F" createVehicleLocal position (_NearestUxoResult select 0);//just for debug _ShowBomb setPos ((_NearestUxoResult select 0) modelToWorld [0,0,0.6]); sleep 3; deleteVehicle _ShowBomb; } else { systemChat "Nothing found"; sleep 3; }; }; }; I made a small change in the code (replaced ArrUXOs for private _ArrUXOs and changed in _allUxo 10m radius for Variable EODS_MDET_var_radius so you don´t have to rewrite it every time you change variable value 😉 ) If you want to turn off searching for UXOs then write CheckActive = FALSE; either in debug console or your script. EDIT: Quote last part of the script, not sure if this affects the other part 🙂 I don´t think this will affect the script. But, of course i´m not sure what value EODS_MDET_var_rnd_radius has and what function EODS_MDET_fnc_randomize does. Well try the code above and we´ll see 🙂. Edited October 17, 2021 by soldierXXXX 1 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 17, 2021 debug works fine now, but is running from the game start in the main menu is that intended or an init error? this seems to work, but on all mines: EODS_MDET_fnc_getNearestMine = { private ["_found", "_nearestMine", "_DetectionPoint", "_allMines", "_mine", "_distance"]; _found = false; _nearestMine = []; //_allMines = allMines; if (currentWeapon player in ["EODS_Detector_Weapon", "EODS_VMH3CS_Weapon"]) then //Checks Player Weapon { _DetectionPoint = "Helper_Base_F" createVehicleLocal getPos Player; // create detection point _DetectionPoint attachto [player,[-0.4,0.8,-0.8],"granat"]; // attach point to player memorypoint "granat" , we can use "granat2" , "LeftHand" , "RightHand" and maybe "aimPoint".... //hideObjectGlobal _DetectionPoint ; //Hiding point.... _allMines = (player nearEntities ["EODS_base_ied_cellphone", 10]) + (player nearEntities ["EODS_Fake_Base", 10]) + allmines ; //EODS_base_ied_Pressure. Custom IEDS. Add Bolts Etc? for "_i" from 0 to ((count _allMines) - 1) do { _mine = _allMines select _i; _distance = _DetectionPoint distance _mine; if (_distance <= EODS_MDET_var_radius) then { if ([getPos player, getDir player, EODS_MDET_var_angle, getPos _mine] call BIS_fnc_inAngleSector) then { if (_found) then { if ((_nearestMine select 1) > _distance) then { _nearestMine = [_mine, _distance]; }; } else { _found = true; _nearestMine = [_mine, _distance]; }; }; }; }; deleteVehicle _DetectionPoint; _nearestMine; }; }; Share this post Link to post Share on other sites
soldierXXXX 97 Posted October 17, 2021 I´m not sure if you need just script for mission or you´re creating a mod ? Well if so, i don´t have experience with creating mods. But i tried to customize the script a little bit. Replace [] spawn part i wrote earlier for this. I assume your script runs in main menu from the begining ? It´s probably not a nice aproach but it should work. I´m sure someone might know better way to do it. 🙂 It works for singleplayer. For multiplayer i think it would need another changes which i´m not sure if i can provide (i´m making mostly singleplayer functions). EODS_MDET_fnc_Detector = { scriptName "EODS_MDET_fnc_Detector"; scopeName "DetectorMain"; if (!canSuspend) exitWith {[] spawn EODS_MDET_fnc_Detector}; waitUntil {sleep 0.1;!isNull findDisplay 46};//waits for mission display; if (isNil "EODS_MDET_fnc_Detector_condition") then { EODS_MDET_fnc_Detector_condition = TRUE; } else { if (EODS_MDET_fnc_Detector_condition) exitWith {systemChat "protection-can´t spawn it twice";breakOut "DetectorMain"}; EODS_MDET_fnc_Detector_condition = TRUE; }; while {!(isNil "EODS_MDET_fnc_Detector_condition")} do { if (!(EODS_MDET_fnc_Detector_condition)) exitWith {systemChat "detection ended";EODS_MDET_fnc_Detector_condition = nil;}; if (isNull findDisplay 46) exitWith {systemChat "detection ended-player is not in mission";EODS_MDET_fnc_Detector_condition = nil;};//if player leaves mission display function ends; if (currentWeapon player in ["EODS_Detector_Weapon", "EODS_VMH3CS_Weapon"]) then { private _NearestUxoResult = call EODS_MDET_fnc_getNearestUxo; //debug-keep sleep command if (_NearestUxoResult isNotEqualTo []) then { systemChat str _NearestUxoResult; private _ShowBomb = "Sign_Arrow_Cyan_F" createVehicleLocal position (_NearestUxoResult select 0);//just for debug _ShowBomb setPos ((_NearestUxoResult select 0) modelToWorld [0,0,0.6]); sleep 3; deleteVehicle _ShowBomb; } else { systemChat "Nothing found"; sleep 3; }; } else { systemChat "you don´t have detector";//also debug sleep 3; }; }; }; [] spawn EODS_MDET_fnc_Detector;//to execute the function spawn this-if it´s mod you´re making you have to implement that somewhere in config (not sure where :D ) //to turn off searching use- EODS_MDET_fnc_Detector_condition = FALSE; or EODS_MDET_fnc_Detector_condition = nil; 1 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 19, 2021 Hi,, yeahh I'm trying to fix a mod, I will test is later and get back to you. Share this post Link to post Share on other sites
soldierXXXX 97 Posted October 19, 2021 Hi again. Yesterday i read few articles and i think i learned something, but i would have to create my own function as addon to see myself how it behaves. At least now i know what you´re trying to achieve. When i thought about it, the function ran in main menu because it was called as mod and there was no restriction present. So i updated the main code and slightly also the search function (global variables were not needed at all). I assume you don´t want your function to end during mission so i removed the restrictions i put earlier. But i decided to keep the debug hints so you can see youself how the function behaves now. It can be simplified even more. Let me know how it works. I´m curious 😄 EODS_MDET_fnc_getNearestUxo = { scriptName "EODS_MDET_fnc_getNearestUxo"; private ["_found", "_nearestUxo", "_DetectionPoint", "_allUxo", "_Uxo", "_distance","_uxoType","_ArrUXOs","_EODVarRadius","_EODVarAngle"]; _uxoType = ["rhsusf_uxo_blu97","BombCluster_03_UXO1_F","BombCluster_02_UXO1_F","BombCluster_01_UXO1_F","BombCluster_03_UXO4_F", "BombCluster_02_UXO4_F","BombCluster_01_UXO4_F","BombCluster_03_UXO2_F","BombCluster_02_UXO2_F","BombCluster_01_UXO2_F", "BombCluster_03_UXO3_F","BombCluster_02_UXO3_F","BombCluster_01_UXO3_F","rhs_uxo_ao1_1","rhs_uxo_ao1_2", "rhs_uxo_ao1_3","rhs_uxo_ptab1m_1","rhs_uxo_ptab1m_2","rhs_uxo_ptab1m_3","rhs_uxo_ptab25ko_1","rhs_uxo_ptab25ko_2", "rhs_uxo_ptab25ko_3","rhs_uxo_ptab25m_1","rhs_uxo_ptab25m_2","rhs_uxo_ptab25m_3","rhs_ammo_uxo_blu97","BombCluster_03_UXO1_Ammo_F", "BombCluster_02_UXO1_Ammo_F","BombCluster_01_UXO1_Ammo_F","BombCluster_03_UXO4_Ammo_F","BombCluster_02_UXO4_Ammo_F", "BombCluster_01_UXO4_Ammo_F","BombCluster_03_UXO2_Ammo_F","BombCluster_02_UXO2_Ammo_F","BombCluster_01_UXO2_Ammo_F", "BombCluster_03_UXO3_Ammo_F","BombCluster_02_UXO3_Ammo_F","BombCluster_01_UXO3_Ammo_F","rhs_ammo_uxo_ao1_1","rhs_ammo_uxo_ao1_2","rhs_ammo_uxo_ao1_3", "rhs_ammo_uxo_ptab1m_1","rhs_ammo_uxo_ptab1m_2","rhs_ammo_uxo_ptab1m_3","rhs_ammo_uxo_ptab25ko_1","rhs_ammo_uxo_ptab25ko_2","rhs_ammo_uxo_ptab25ko_3", "rhs_ammo_uxo_ptab25m_1","rhs_ammo_uxo_ptab25m_2","rhs_ammo_uxo_ptab25m_3" ]; _EODVarRadius = 10; _EODVarAngle = 90; _found = false; _nearestUxo = []; _DetectionPoint = "Helper_Base_F" createVehicleLocal getPos Player; // create detection point _DetectionPoint attachto [player,[-0.4,0.8,-0.8],"granat"]; // attach point to player memorypoint "granat" , we can use "granat2" , "LeftHand" , "RightHand" and maybe "aimPoint".... _allUxo = position player nearObjects ["mineBase",_EODVarRadius]; _ArrUXOs = []; { if (typeOf _x in _uxoType) then {_ArrUXOs pushBack _x}; } forEach _allUxo; for "_i" from 0 to ((count _ArrUXOs) - 1) do { _Uxo = _ArrUXOs select _i; _distance = _DetectionPoint distance _Uxo; if (_distance <= _EODVarRadius) then { if ([getPos player, getDir player, _EODVarAngle, getPos _Uxo] call BIS_fnc_inAngleSector) then { if (_found) then { if ((_nearestUxo select 1) > _distance) then { _nearestUxo = [_Uxo, _distance]; }; } else { _found = true; _nearestUxo = [_Uxo, _distance]; }; }; }; }; detach _DetectionPoint; deleteVehicle _DetectionPoint; _nearestUxo; }; EODS_MDET_fnc_Detector = { scriptName "EODS_MDET_fnc_Detector"; scopeName "DetectorMain"; if (!canSuspend) exitWith {[] spawn EODS_MDET_fnc_Detector};//function needs to run in scheduled environment if (allDisplays isEqualTo [findDisplay 0]) exitWith {};//prevention to not run script in main menu (untested)-might need to add other displays that game loads in main menu (if any other than Display #0) you can find currently running displays with systemChat str allDisplays; if (!hasInterface) exitWith {};//prevention to not run script on dedicated servers or headless clients (untested); waitUntil {sleep 0.5;!isNull player};//function waits until player is ready to play- also JIP protection (untested); while {TRUE} do { if (currentWeapon player in ["EODS_Detector_Weapon", "EODS_VMH3CS_Weapon"]) then { private _NearestUxoResult = call EODS_MDET_fnc_getNearestUxo; //debug-keep sleep command if (_NearestUxoResult isNotEqualTo []) then { systemChat str _NearestUxoResult; private _ShowBomb = "Sign_Arrow_Cyan_F" createVehicleLocal position (_NearestUxoResult select 0);//just for debug _ShowBomb setPos ((_NearestUxoResult select 0) modelToWorld [0,0,0.6]); sleep 3; deleteVehicle _ShowBomb; } else { systemChat "Nothing found"; sleep 3; }; } else { systemChat "you don´t have detector";//also debug sleep 3; }; }; }; //define both functions in CfgFunctions and with EODS_MDET_fnc_Detector set the attribute postInit = 1;(function call itself automaticly) And also, i want to thank @Leopard20 for the tip 🙂. 2 Share this post Link to post Share on other sites
_-xXShArK_OGXx-_ 6 Posted October 24, 2021 [SOLVED] ->> Script was tweaked. BIG SHOUT OUT to @soldierXXXX thx for your help and for finding the errors in the script. and thx @Leopard20 this tip will help in other places too. Share this post Link to post Share on other sites