Buy/Sell list? Hmm, where's that?
Here's what I'm doing now:
This will get the item for you. It is currently broken on MOST vendors.

It does work on the treated healing kit vendor though.
Quote:
foreach (WorldObject obj in Util.Core.WorldFilter.OpenVendor)
{
if (obj.Name.Contains(ItemName))
{
Item = obj;
break;
}
}
Then, my next bit of code to determine if we need to sell some items so we can purchase it, note that its not completed as vendors are currently broken:
Quote:
if (Item.Values(LongValueKey.StackCount) == 0)
{
// Item is purchased one at a time
if (Items.Money_Pyreals.Count >= Item.Values(LongValueKey.Value) * Util.Core.WorldFilter.OpenVendor.SellRate)
{
WaitingForApproachMsg = true;
// We have enough money to purchase this item
ActionQueue.Add(new VendorAddBuyList(Item.Id, 1));
ActionQueue.Add(new VendorBuyAll());
}
else
{
// We need to sell some stuff
int CostEach = (int)Math.Ceiling(Item.Values(LongValueKey.Value) * Util.Core.WorldFilter.OpenVendor.SellRate);
int MinPyreals = CostEach;
int MaxPyreals = CostEach * ((ItemsOriginallyHad + count) - ItemsCurrentlyHave);
if (!AddItemsToSell(MinPyreals, MaxPyreals))
{
Stop();
Util.Debug("Unable to BuyItem from vendor. Not enough items to sell to purchase item: " + ItemName + "."

;
return;
}
WaitingForApproachMsg = true;
ActionQueue.Add(new VendorSellAll());
}
}
else
{
// Item is purchased in stacks
Stop();
Util.Debug("Unable to BuyItem from vendor. Method not implemented."

;
}
To give you an example, my buylist class:
Quote:
using System;
using Decal.Adapter.Wrappers;
namespace Mag_Tools.Actions
{
public class VendorAddBuyList : Action
{
private int itemId;
private int count;
public VendorAddBuyList(int itemId, int count)
{
this.itemId = itemId;
this.count = count;
}
protected override bool Starting()
{
try
{
if (Util.Core.WorldFilter.OpenVendor == null)
{
Util.Debug("Unable to AddBuyList to vendor. OpenVendor == null"

;
return false;
}
return true;
}
catch (Exception ex) { Util.LogError(ex); return false; }
}
protected override void ActionThink()
{
try
{
Util.Debug("Trying to AddBuyList to vendor."

;
Util.QueueDecalAction(delegate() { Util.Host.Actions.VendorAddBuyList(itemId, count); });
Stop();
Util.Debug("Vendor AddBuyList completed."

;
}
catch (Exception ex) { Util.LogError(ex); }
}
}
}
This might help spark some ideas. I'm using a queue system similar to the one found in goarrow.