****I posted in the wrong section can it be moved*****
I've been trying to code a script to loot gold from corpses.
I am getting the error Queue Empty at what seems to be very random times so I was thinking would lag be affecting it some way.
I am not using Queues tho just lists so should I even be seeing that error. Anyone see what might be wrong.
the code falls on the line
var corpses = Item.Find(typeof(Corpse), 0x0, false);
public void StartLooting()
{
List<Item> lootItems = new List<Item>();
Thread.Sleep(500);
try
{
while (Looting)
{
var corpses = Item.Find(typeof(Corpse), 0x0, false);
if (corpses.Count > 0)
{
foreach (Corpse corpse in corpses)
{
if (corpse.Distance < 4)
{
corpse.DoubleClick();
}
Thread.Sleep(500);
var goldList = Item.Find(typeof(Gold), corpse.Serial.Value, false);
foreach (Gold gold in goldList)
{
lootItems.Add(new Loot(gold.Serial));
}
if (lootItems.Any())
{
foreach (Item loot in lootItems)
{
loot.MoveItem(Player.Backpack);
}
}
Looting = false;
Thread.Sleep(500);
}
}
}
}
catch (Exception e)
{
this.Dispatcher.Invoke((Action)(() =>
{
Clipboard.SetText(e.StackTrace);
listBox.Items.Clear();
listBox.Items.Add(e);
}));
}
}
Here's the stack trace.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Queue`1.Dequeue()
at StealthAPI.StealthClient.WaitReply[T](PacketType type)
at StealthAPI.StealthClient.SendPacket[T](PacketType packetType, Object[] parameters)
at StealthAPI.Stealth.FindTypeEx(UInt16 objType, UInt16 color, UInt32 container, Boolean inSub)
at ScriptSDK.Engines.Scanner.<>c__DisplayClass23_2`1.<Find>b__2(UInt32 le)
at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__22`3.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
at ScriptSDK.Engines.Scanner.Find[T](List`1 Graphics, List`1 Colors, List`1 Locations, Boolean SubSearch)
at ScriptSDK.Items.Item.Find(Type type, List`1 Locations, Boolean SubSearch)
at ScriptSDK.Items.Item.Find(Type type, UInt32 Location, Boolean SubSearch)
at AutoLoot.MainWindow.StartLooting() in C:\Users\GreyWalker\Desktop\UOStuff\Projects\AutoLoot\MainWindow.xaml.cs:line 58