From b6e124d34032bf6f1c8a2fa899d716d35755b35b Mon Sep 17 00:00:00 2001
From: PabstMirror <elephantisaterriblemascot@gmail.com>
Date: Thu, 16 Jul 2015 19:12:11 -0500
Subject: [PATCH] #1856 - Close huntIR monitor if item removed

---
 addons/huntir/functions/fnc_cam.sqf    | 5 +++++
 addons/huntir/functions/fnc_huntir.sqf | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/addons/huntir/functions/fnc_cam.sqf b/addons/huntir/functions/fnc_cam.sqf
index 264c0c74b6..bcc553fff0 100644
--- a/addons/huntir/functions/fnc_cam.sqf
+++ b/addons/huntir/functions/fnc_cam.sqf
@@ -63,6 +63,11 @@ GVAR(no_cams) sort true;
     GVAR(no_cams) set [_forEachIndex, _x select 1];
 } forEach GVAR(no_cams);
 [{
+    //Close monitor if we no longer have the item:
+    if ((!([ACE_player, "ACE_HuntIR_monitor"] call EFUNC(common,hasItem))) && {!isNull (uiNameSpace getVariable ["ace_huntir_monitor", displayNull])}) then {
+        closeDialog 0;
+    };
+
     GVAR(nearHuntIRs) = ACE_player nearEntities ["ACE_HuntIR", HUNTIR_MAX_TRANSMISSION_RANGE];
     {
         if (((getPosVisual _x) select 2) > 20 && {!(_x in GVAR(no_cams))} && {_x getHitPointDamage "HitCamera" < 0.25}) then {
diff --git a/addons/huntir/functions/fnc_huntir.sqf b/addons/huntir/functions/fnc_huntir.sqf
index f8aed93880..27fd5e280b 100644
--- a/addons/huntir/functions/fnc_huntir.sqf
+++ b/addons/huntir/functions/fnc_huntir.sqf
@@ -38,6 +38,11 @@ createDialog "ace_huntir_cam_dialog_off";
         GVAR(messageSearching) = toArray "Searching.....";            
         GVAR(messageConnecting) = toArray "Connecting.....";
         [{
+            //Close monitor if we no longer have item:
+            if ((!([ACE_player, "ACE_HuntIR_monitor"] call EFUNC(common,hasItem))) && {!isNull (uiNameSpace getVariable ["ace_huntir_monitor", displayNull])}) then {
+                closeDialog 0;
+            };
+        
             private ["_elapsedTime", "_nearestHuntIRs"];
             _elapsedTime = ACE_time - GVAR(startTime);
             _nearestHuntIRs = ACE_player nearEntities ["ACE_HuntIR", HUNTIR_MAX_TRANSMISSION_RANGE];