IndexOutOfRangeException at CargoHUDError

I keep getting this error

Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)

at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <363758bc5c2c419d98e9ca4a0d64722c>:0

at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <363758bc5c2c419d98e9ca4a0d64722c>:0

at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0

I'm not really sure if it matters or not since it seems to be working. At least it was with the previous version. Haven't had a chance to pop on the server yet today. I've unloaded it. Wiped both lang files and the config and uploaded the plugin again. Still getting the error.



Merged post

Sorry for net getting back sooner. The plugin is working properly as far as I can tell. Every time I have checked they're on the map. But the error's still showing in the console.
getting this error in rcon
Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
  at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <5ba6e2818c9746958d62e4cb1539c27e>:0 
  at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <5ba6e2818c9746958d62e4cb1539c27e>:0 
  at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0​
09:18 [Error] Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.6' (IndexOutOfRangeException: Index was outside the bounds of the array.)
  at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <4d54db0c0e7e46a5a8e61a265a15f741>:0
  at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <4d54db0c0e7e46a5a8e61a265a15f741>:0
  at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0
Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <78a72376ce994bcbb720b23f415ce831>:0
at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <78a72376ce994bcbb720b23f415ce831>:0
at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0

Same here with 0.0.7:

Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
  at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <69f1d20a174348a2832f7afd411c3180>:0
at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <69f1d20a174348a2832f7afd411c3180>:0
at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0
I get this in my console and I'm wondering if this is the reason my server wiped itself.

[Error] Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <a405a56c8bb044bfbc50ab0a6bf44d85>:0

at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <a405a56c8bb044bfbc50ab0a6bf44d85>:0

at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0
Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <cdd72e66f3754e14a9c587bee8434ced>:0
at Oxide.Plugins.MapMyAirDrop+<OnEntitySpawned>c__AnonStorey0.<>m__0 () [0x00011] in <cdd72e66f3754e14a9c587bee8434ced>:0
at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0
Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
  at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <0d10dd057445408ead72d7314ac31ab8>:0
at Oxide.Plugins.MapMyAirDrop+c__AnonStorey0.<>m__0 () [0x00011] in <0d10dd057445408ead72d7314ac31ab8>:0
at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <4452f821def6406d834e4149849fe7ea>:0
I wrote a fix for it.
You can simply backup and replace the this function in line ~288
private void CargoHUD(string reason)​

Edited function:

private void CargoHUD(string reason)
		{
			if (debug) {Puts($"HUD STARTS");}
			DestroyAllHUD();
			HUDlist.Clear();
			double colonnegauche = 0.10;
			double colonnedroite = colonnegauche + 0.07;
			double lignehaut = 1.00;
			double lignebas = lignehaut - 0.05;            
            int round = 0;
			List<Vector3> positionlist = new List<Vector3>();
			List<BaseEntity> droplist = new List<BaseEntity>();
			Vector3[] positionarray;			
			BaseEntity[] droparray;
            /*if (reason == "spawn")
            {

            }*/
            if (reason == "dropped")
            {
				if (debug) {Puts($"HUD FOR DROP");}
				foreach (var Suppliez in entsupply)
				{
					Vector3 supplyupdated = Suppliez.Key.transform.position;
					if (debug) {Puts($"REFRESHED SUPPLY POSITION {supplyupdated}");}
					dropposition.Remove(Suppliez.Key);
					dropposition.Add(Suppliez.Key, supplyupdated);
				}
				foreach (var pair in dropposition)
				{
					//droplist.Remove(pair.Key);					
					droplist.Add(pair.Key);
					positionlist.Add(pair.Value);
				}
                droparray = droplist.ToArray();
                positionarray = positionlist.ToArray();
            	int dropnum = droplist.Count;
            	string message = "";
				List<string> HUDforplayers = new List<string>();
				foreach (var player in BasePlayer.activePlayerList.ToList())
				{
					HUDforplayers = new List<string>();
					
					foreach(Vector3 drop_posi in positionlist)
					{
						if (debug) {Puts($"round {round} on {dropnum}");}						
						double colonnedecalage = 0.08 * round++;
						bool HUDview = permission.UserHasPermission(player.UserIDString, MapMyAirdropHUD);
						var CuiElement = new CuiElementContainer();
						string CargoHUDBanner = CuiElement.Add(new CuiPanel{Image ={Color = "0.5 0.5 0.5 0.2"},RectTransform ={AnchorMin = $"{colonnegauche + colonnedecalage} {lignebas}",AnchorMax = $"{colonnedroite + colonnedecalage} {lignehaut}"},CursorEnabled = false});
						//}, new CuiElement().Parent = "Overlay", CargoHUDBanner);
						var closeButton = new CuiButton{Button ={Close = CargoHUDBanner,Color = "0.0 0.0 0.0 0.6"},RectTransform ={AnchorMin = "0.90 0.00",AnchorMax = "1.00 1.00"},Text ={Text = "X",FontSize = 8,Align = TextAnchor.MiddleCenter}};
						CuiElement.Add(closeButton, CargoHUDBanner);	// close button in case plugin reload while HUD are on.	
   					    if (debug) {Puts($"PLAYER BEFORE DISTANCE");}						
                        int dist = (int)Vector3.Distance(drop_posi, player.transform.position);						
                        message = String.Format(lang.GetMessage("HUDDistanceMsg", this, player.UserIDString),dist.ToString());
				        if (debug) {Puts($"PLAYER DISTANCE MESSAGE DONE : {message}");}
                        var playerdistance = CuiElement.Add(new CuiLabel
                        {Text = {Text = String.Format(lang.GetMessage("HUDAirdropMsg", this, player.UserIDString),round,message), Color = "1.0 1.0 1.0 1.0", FontSize = 10, Align = TextAnchor.MiddleCenter},
                        RectTransform = {AnchorMin = $"0.0 0.0", AnchorMax = $"0.85 1.0"}
                        }, CargoHUDBanner);
						if (HUDview)
						{
							CuiHelper.AddUi(player, CuiElement);
						}
						HUDforplayers.Add(CargoHUDBanner);
					}
					
					HUDlist.Remove(player);
					HUDlist.Add(player, HUDforplayers);
				}
            }
		}

It will loop through all drops with a "foreach()" instead of a wrong indexed "for()".

Toliman
I wrote a fix for it.
You can simply backup and replace the this function in line ~288
private void CargoHUD(string reason)​

Edited function:

private void CargoHUD(string reason)
		{
			if (debug) {Puts($"HUD STARTS");}
			DestroyAllHUD();
			HUDlist.Clear();
			double colonnegauche = 0.10;
			double colonnedroite = colonnegauche + 0.07;
			double lignehaut = 1.00;
			double lignebas = lignehaut - 0.05;            
            int round = 0;
			List<Vector3> positionlist = new List<Vector3>();
			List<BaseEntity> droplist = new List<BaseEntity>();
			Vector3[] positionarray;			
			BaseEntity[] droparray;
            /*if (reason == "spawn")
            {

            }*/
            if (reason == "dropped")
            {
				if (debug) {Puts($"HUD FOR DROP");}
				foreach (var Suppliez in entsupply)
				{
					Vector3 supplyupdated = Suppliez.Key.transform.position;
					if (debug) {Puts($"REFRESHED SUPPLY POSITION {supplyupdated}");}
					dropposition.Remove(Suppliez.Key);
					dropposition.Add(Suppliez.Key, supplyupdated);
				}
				foreach (var pair in dropposition)
				{
					//droplist.Remove(pair.Key);					
					droplist.Add(pair.Key);
					positionlist.Add(pair.Value);
				}
                droparray = droplist.ToArray();
                positionarray = positionlist.ToArray();
            	int dropnum = droplist.Count;
            	string message = "";
				List<string> HUDforplayers = new List<string>();
				foreach (var player in BasePlayer.activePlayerList.ToList())
				{
					HUDforplayers = new List<string>();
					
					foreach(Vector3 drop_posi in positionlist)
					{
						if (debug) {Puts($"round {round} on {dropnum}");}						
						double colonnedecalage = 0.08 * round++;
						bool HUDview = permission.UserHasPermission(player.UserIDString, MapMyAirdropHUD);
						var CuiElement = new CuiElementContainer();
						string CargoHUDBanner = CuiElement.Add(new CuiPanel{Image ={Color = "0.5 0.5 0.5 0.2"},RectTransform ={AnchorMin = $"{colonnegauche + colonnedecalage} {lignebas}",AnchorMax = $"{colonnedroite + colonnedecalage} {lignehaut}"},CursorEnabled = false});
						//}, new CuiElement().Parent = "Overlay", CargoHUDBanner);
						var closeButton = new CuiButton{Button ={Close = CargoHUDBanner,Color = "0.0 0.0 0.0 0.6"},RectTransform ={AnchorMin = "0.90 0.00",AnchorMax = "1.00 1.00"},Text ={Text = "X",FontSize = 8,Align = TextAnchor.MiddleCenter}};
						CuiElement.Add(closeButton, CargoHUDBanner);	// close button in case plugin reload while HUD are on.	
   					    if (debug) {Puts($"PLAYER BEFORE DISTANCE");}						
                        int dist = (int)Vector3.Distance(drop_posi, player.transform.position);						
                        message = String.Format(lang.GetMessage("HUDDistanceMsg", this, player.UserIDString),dist.ToString());
				        if (debug) {Puts($"PLAYER DISTANCE MESSAGE DONE : {message}");}
                        var playerdistance = CuiElement.Add(new CuiLabel
                        {Text = {Text = String.Format(lang.GetMessage("HUDAirdropMsg", this, player.UserIDString),round,message), Color = "1.0 1.0 1.0 1.0", FontSize = 10, Align = TextAnchor.MiddleCenter},
                        RectTransform = {AnchorMin = $"0.0 0.0", AnchorMax = $"0.85 1.0"}
                        }, CargoHUDBanner);
						if (HUDview)
						{
							CuiHelper.AddUi(player, CuiElement);
						}
						HUDforplayers.Add(CargoHUDBanner);
					}
					
					HUDlist.Remove(player);
					HUDlist.Add(player, HUDforplayers);
				}
            }
		}

It will loop through all drops with a "foreach()" instead of a wrong indexed "for()".

Thank you, the fix works so far it seems. I will update this again if not.

Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.)
  at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <0039c6c27a7e40428f14bca69f5b18c4>:0
  at Oxide.Plugins.MapMyAirDrop+c__AnonStorey0.<>m__0 () [0x00011] in <0039c6c27a7e40428f14bca69f5b18c4>:0
  at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <33287985591c40d6983f0b8f0e915565>:0

All working good but how to fix that error?

I tried that fix and it still gives the error Failed to run a 5.00 timer in 'MapMyAirDrop v0.0.7' (IndexOutOfRangeException: Index was outside the bounds of the array.) at Oxide.Plugins.MapMyAirDrop.CargoHUD (System.String reason) [0x00361] in <0039c6c27a7e40428f14bca69f5b18c4>:0 at Oxide.Plugins.MapMyAirDrop+c__AnonStorey0.<>m__0 () [0x00011] in <0039c6c27a7e40428f14bca69f5b18c4>:0 at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00018] in <33287985591c40d6983f0b8f0e915565>:0