--call global couting function, store result in local var.
local remainingMunitions = gKH.Groups.CountGroupMunitions('Blue','SAG_1',3714,false)

--check if it's valid and under our set limit, if it is go ahead and do something.
if (remainingMunitions ~=nil) and remainingMunitions <= gKH.SceneGlobals.RemainingRIM174IBs then
    --Do something useful
    gKH.SceneGlobals.HoldFireAndDisableMissions()
    ScenEdit_SetEvent('ScanEvery5Seconds',{IsActive=false});
    --messagebox is just for debugging.
    ScenEdit_MsgBox("Number of remaining munitions less than or equal to set amount. changed missions", 0)
else
    --messagebox is just for debugging.
    --ScenEdit_MsgBox("Number of remaining munitions this second:" .. tostring(remainingMunitions), 0)
end

