// returns true if the user has weird crap in their trade window. public bool HasNonPureInTrade() { foreach (TradeUserAssets asset in Trade.OtherOfferedItems) { Inventory.Item item = Trade.OtherInventory.GetItem(asset.assetid); Schema.Item schemaItem = Trade.CurrentSchema.GetItem(item.Defindex); if (!schemaItem.IsPure()) { return(true); } } return(false); }
public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem) { Log.Info("Added item {0}{1} (defindex #{2}).", Order.GetQualityString(inventoryItem.Quality), schemaItem.ItemName, schemaItem.Defindex); if (!schemaItem.IsPure()) { Bot.GetInventory(); bool found = false; foreach (Order o in Bot.Orders.BuyOrders) { if (o.MatchesItem(inventoryItem)) { found = true; if (Bot.MyInventory.TotalPure() < o.Price) { Log.Warn("Out of metal for buy orders! Not enough metal to buy {0}.", schemaItem.ItemName); SendTradeMessage("Unfortunately I am out of metal and cannot buy anything at the moment."); SendTradeMessage("Enter 'buy' to get a list of the items I am selling."); } else if (Bot.MyInventory.GetItemsByDefindex(o.Defindex, o.Quality).Count >= o.MaxStock) { Log.Warn("Full stock for item {0}.", schemaItem.ItemName); SendTradeMessage("Unfortunately I have full stock and cannot buy your {0}.", schemaItem.ItemName); SendTradeMessage("Enter 'buy' to get a list of the items I am selling."); } else { ActiveOrder = o; SendTradeMessage(o.ToString(Trade.CurrentSchema)); AddPure(ActiveOrder.Price); } } } if (!found) { SendTradeMessage("I am currently not buying that item at the moment."); SendTradeMessage("Enter 'buy' to get a list of the items I am selling."); } } else { if (schemaItem.Defindex == TF2Value.SCRAP_DEFINDEX) { AmountAdded += TF2Value.Scrap; } else if (schemaItem.Defindex == TF2Value.RECLAIMED_DEFINDEX) { AmountAdded += TF2Value.Reclaimed; } else if (schemaItem.Defindex == TF2Value.REFINED_DEFINDEX) { AmountAdded += TF2Value.Refined; } else if (schemaItem.Defindex == TF2Value.KEY_DEFINDEX) { AmountAdded += TF2Value.Key; } else if (ActiveOrder != null) { SendTradeMessage("Sorry, but I cannot accept any {0} as valid payment.", schemaItem.ItemName); } if (AmountAdded == ActiveOrder.Price) { SendTradeMessage("You have paid the correct amount."); } else if (AmountAdded > ActiveOrder.Price) { SendTradeMessage("You are paying too much! The price for the {0} is {1}.", ActiveOrder.GetSearchString(Trade.CurrentSchema), ActiveOrder.Price.ToRefString()); } } }