public bool AddItem(TradeUserAssets item) { var slot = NextTradeSlot(); bool success = RetryWebRequest(() => session.AddItemWebCmd(item.assetid, slot, item.appid, item.contextid)); if (success) { myOfferedItemsLocalCopy[slot] = item; } return(success); }
public bool AddItem(TradeUserAssets item) { var slot = NextTradeSlot(); bool ok = session.AddItemWebCmd(item.assetid, slot, item.appid, item.contextid); if (!ok) { throw new TradeException("The Web command to add the Item failed"); } myOfferedItems[slot] = item.assetid; return(true); }
private Schema.Item GetItemFromPrivateBp(TradeUserAssets asset) { if (OtherPrivateInventory == null) { // get the foreign inventory var f = session.GetForiegnInventory(OtherSID, asset.contextid, asset.appid); OtherPrivateInventory = new ForeignInventory(f); } ushort defindex = OtherPrivateInventory.GetDefIndex(asset.assetid); Schema.Item schemaItem = CurrentSchema.GetItem(defindex); return(schemaItem); }
private Schema.Item GetItemFromPrivateBp(TradeUserAssets asset) { if (OtherPrivateInventory == null) { dynamic foreignInventory = session.GetForeignInventory(OtherSID, asset.contextid, asset.appid); if (foreignInventory == null || foreignInventory.success == null || !foreignInventory.success.Value) { return(null); } OtherPrivateInventory = new ForeignInventory(foreignInventory); } int defindex = OtherPrivateInventory.GetDefIndex(asset.assetid); Schema.Item schemaItem = CurrentSchema.GetItem(defindex); return(schemaItem); }
/// <summary> /// Gets an item from a TradeEvent, and passes it into the UserHandler's implemented OnUserAddItem([...]) routine. /// Passes in null items if something went wrong. /// </summary> private void FireOnUserAddItem(TradeUserAssets asset) { if (MeIsReady) { SetReady(false); } if (OtherInventory != null && !OtherInventory.IsPrivate) { Inventory.Item item = OtherInventory.GetItem(asset.assetid); if (item != null) { Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); if (schemaItem == null) { Console.WriteLine("User added an unknown item to the trade."); } OnUserAddItem(schemaItem, item); } else { item = new Inventory.Item { Id = asset.assetid, AppId = asset.appid, ContextId = asset.contextid }; //Console.WriteLine("User added a non TF2 item to the trade."); OnUserAddItem(null, item); } } else { var schemaItem = GetItemFromPrivateBp(asset); if (schemaItem == null) { Console.WriteLine("User added an unknown item to the trade."); } OnUserAddItem(schemaItem, null); // todo: figure out what to send in with Inventory item..... } }
/// <summary> /// Gets an item from a TradeEvent, and passes it into the UserHandler's implemented OnUserRemoveItem([...]) routine. /// Passes in null items if something went wrong. /// </summary> /// <returns></returns> private void FireOnUserRemoveItem(TradeUserAssets asset) { if (MeIsReady) { SetReady(false); } if (OtherInventory != null) { Inventory.Item item = OtherInventory.GetItem(asset.assetid); if (item != null) { Schema.Item schemaItem = CurrentSchema.GetItem(item.Defindex); if (schemaItem == null) { // TODO: Add log (counldn't find item in CurrentSchema) } OnUserRemoveItem(schemaItem, item); } else { // TODO: Log this (Couldn't find item in user's inventory can't find item in CurrentSchema item = new Inventory.Item { Id = asset.assetid, AppId = asset.appid, ContextId = asset.contextid }; OnUserRemoveItem(null, item); } } else { var schemaItem = GetItemFromPrivateBp(asset); if (schemaItem == null) { // TODO: Add log (counldn't find item in CurrentSchema) } OnUserRemoveItem(schemaItem, null); } }
public bool AddItem(TradeUserAssets item) { var slot = NextTradeSlot(); bool success = false; if (item.iscurrency) { success = RetryWebRequest(() => session.AddCurrencyWebCmd(item.assetid, item.amount, item.appid, item.contextid)); } else { success = RetryWebRequest(() => session.AddItemWebCmd(item.assetid, slot, item.appid, item.contextid, item.amount)); } if (success) { steamMyOfferedItems[slot] = new GenericInventory.GenericItem(item.appid, item.contextid, item.assetid, item.amount, item.iscurrency); } return(success); }
public bool RemoveItem(TradeUserAssets item) { return(RemoveItem(item.assetid, item.appid, item.contextid, item.amount, item.iscurrency)); }
private void CopyNewAssets(List<ulong> dest, TradeUserAssets[] assetList) { if (assetList == null) return; //Console.WriteLine("clearing dest"); dest.Clear(); foreach (var asset in assetList) { dest.Add(asset.assetid); //Console.WriteLine(asset.assetid); } }
public bool RemoveItem(TradeUserAssets item) { return RemoveItem(item.assetid, item.appid, item.contextid); }
public bool AddItem(TradeUserAssets item) { var slot = NextTradeSlot(); bool ok = session.AddItemWebCmd(item.assetid, slot, item.appid, item.contextid); if (!ok) throw new TradeException("The Web command to add the Item failed"); myOfferedItems[slot] = item.assetid; return true; }
private bool HandleTradeOngoing(TradeStatus status) { if (status.newversion) { HandleTradeVersionChange(status); return(true); } else if (status.version > session.Version) { // oh crap! we missed a version update abort so we don't get // scammed. if we could get what steam thinks what's in the // trade then this wouldn't be an issue. but we can only get // that when we see newversion == true throw new TradeException("The trade version does not match. Aborting."); } // Update Local Variables if (status.them != null) { OtherIsReady = status.them.ready == 1; MeIsReady = status.me.ready == 1; OtherUserAccepted = status.them.confirmed == 1; //Similar to the logic Steam uses to determine whether or not to show the "waiting" spinner in the trade window otherUserTimingOut = (status.them.connection_pending || status.them.sec_since_touch >= 5); } bool otherUserDidSomething = false; var events = status.GetAllEvents(); foreach (var tradeEvent in events.OrderBy(o => o.timestamp)) { if (eventList.Contains(tradeEvent)) { continue; } //add event to processed list, as we are taking care of this event now eventList.Add(tradeEvent); bool isBot = tradeEvent.steamid == MySteamId.ConvertToUInt64().ToString(); // dont process if this is something the bot did if (isBot) { continue; } otherUserDidSomething = true; switch ((TradeEventType)tradeEvent.action) { case TradeEventType.ItemAdded: TradeUserAssets newAsset = new TradeUserAssets(tradeEvent.appid, tradeEvent.contextid, tradeEvent.assetid); if (!otherOfferedItems.Contains(newAsset)) { otherOfferedItems.Add(newAsset); FireOnUserAddItem(newAsset); } break; case TradeEventType.ItemRemoved: TradeUserAssets oldAsset = new TradeUserAssets(tradeEvent.appid, tradeEvent.contextid, tradeEvent.assetid); if (otherOfferedItems.Contains(oldAsset)) { otherOfferedItems.Remove(oldAsset); FireOnUserRemoveItem(oldAsset); } break; case TradeEventType.UserSetReady: OnUserSetReady(true); break; case TradeEventType.UserSetUnReady: OnUserSetReady(false); break; case TradeEventType.UserAccept: OnUserAccept(); break; case TradeEventType.UserChat: OnMessage(tradeEvent.text); break; default: throw new TradeException("Unknown event type: " + tradeEvent.action); } } if (status.logpos != 0) { session.LogPos = status.logpos; } return(otherUserDidSomething); }
public bool RemoveItem(TradeUserAssets item) { return(RemoveItem(item.assetid, item.appid, item.contextid)); }
public bool RemoveItem(TradeUserAssets item) { return(RemoveItem(item.AssetId, item.AppId, item.ContextId)); }