public static void SetItemPosition(Bot bot, SteamTrade.Inventory.Item item, short position) { byte[] bPos = BitConverter.GetBytes(position); byte[] bClass = BitConverter.GetBytes(item.InventoryToken); byte[] nInv = new byte[] { bPos[0], bPos[1], bClass[2], bClass[3] }; uint newInventoryDescriptor = BitConverter.ToUInt32(nInv, 0); var aMsg = new ClientGCMsg <MsgSetItemPosition>(); aMsg.Write((long)item.Id); aMsg.Write((uint)newInventoryDescriptor); bot.SteamGC.Send(aMsg, 570); }
/// <summary> /// Sets an item's 1-based position in the backpack /// </summary> /// <param name="bot">The current Bot</param> /// <param name="item">The 64-bit Item ID to move</param> /// <param name="position">The 1-based integer position of the item</param> /// <remarks> /// You must have set the current game to 440 for this to do anything. /// </remarks> public static void SetItemPosition(Bot bot, SteamTrade.Inventory.Item item, short position) { if (bot.CurrentGame != 440) { throw new Exception("SteamBot is not ingame with AppID 440; current AppID is " + bot.CurrentGame); } byte[] bPos = BitConverter.GetBytes(position); byte[] bClass = BitConverter.GetBytes(item.ClassesEquipped); byte[] nInv = new byte[] { bPos[0], bPos[1], bClass[0], bClass[1] }; uint newInventoryDescriptor = BitConverter.ToUInt32(nInv, 0); var aMsg = new ClientGCMsg <MsgSetItemPosition>(); aMsg.Write((long)item.Id); aMsg.Write((uint)newInventoryDescriptor); bot.SteamGameCoordinator.Send(aMsg, 440); }
public static string GetPrice(int defindex, int quality, SteamTrade.Inventory.Item inventoryItem, bool gifted = false, int attribute = 0) { try { double value = BackpackTF.CurrentSchema.Response.Prices[defindex][quality][attribute].Value; double keyValue = BackpackTF.CurrentSchema.Response.Prices[5021][6][0].Value; double billsValue = BackpackTF.CurrentSchema.Response.Prices[126][6][0].Value; double budValue = BackpackTF.CurrentSchema.Response.Prices[143][6][0].Value; var item = SteamTrade.Trade.CurrentSchema.GetItem(defindex); string result = ""; if (inventoryItem.IsNotCraftable) { value = value / 2.0; } if (inventoryItem.IsNotTradeable) { value = value / 2.0; } if (gifted) { value = value * 0.75; } if (quality == 3) { if (item.CraftMaterialType == "weapon") { int level = inventoryItem.Level; switch (level) { case 0: value = billsValue + 5.11; break; case 1: value = billsValue; break; case 42: value = value * 10.0; break; case 69: value = billsValue; break; case 99: value = billsValue; break; case 100: value = billsValue; break; default: break; } } else if (item.CraftMaterialType == "hat") { int level = inventoryItem.Level; switch (level) { case 0: value = value * 10.0; break; case 1: value = value * 5.0; break; case 42: value = value * 3.0; break; case 69: value = value * 4.0; break; case 99: value = value * 4.0; break; case 100: value = value * 6.0; break; default: break; } } } if (value >= budValue * 1.33) { value = value / budValue; result = value.ToString("0.00") + " buds"; } else if (value >= keyValue && !item.ItemName.EndsWith("Key")) { value = value / keyValue; result = value.ToString("0.00") + " keys"; } else { result = value.ToString("0.00") + " ref"; } return(result); } catch { return("Unknown"); } }
string GetItemName(SteamTrade.Schema.Item schemaItem, SteamTrade.Inventory.Item inventoryItem, bool id = false) { var currentItem = SteamTrade.Trade.CurrentSchema.GetItem(schemaItem.Defindex); string name = ""; var type = Convert.ToInt32(inventoryItem.Quality.ToString()); if (Util.QualityToName(type) != "Unique") { name += Util.QualityToName(type) + " "; } name += currentItem.ItemName; name += " (" + SteamTrade.Trade.CurrentItemsGame.GetItemRarity(schemaItem.Defindex.ToString()) + ")"; if (currentItem.CraftMaterialType == "supply_crate") { for (int count = 0; count < inventoryItem.Attributes.Length; count++) { name += " #" + (inventoryItem.Attributes[count].FloatValue); } } try { int size = inventoryItem.Attributes.Length; for (int count = 0; count < size; count++) { if (inventoryItem.Attributes[count].Defindex == 186) { name += " (Gifted)"; } } } catch { // Item has no attributes... or something. } if (currentItem.Name == "Wrapped Gift") { // Untested! try { int size = inventoryItem.Attributes.Length; for (int count = 0; count < size; count++) { var containedItem = SteamTrade.Trade.CurrentSchema.GetItem(inventoryItem.ContainedItem.Defindex); name += " (Contains: " + containedItem.ItemName + ")"; } } catch { // Item has no attributes... or something. } } if (!string.IsNullOrWhiteSpace(inventoryItem.CustomName)) { name += " (Custom Name: " + inventoryItem.CustomName + ")"; } if (!string.IsNullOrWhiteSpace(inventoryItem.CustomDescription)) { name += " (Custom Desc.: " + inventoryItem.CustomDescription + ")"; } if (id) { name += " :" + inventoryItem.Id; } return(name); }
string GetItemName(SteamTrade.Schema.Item schemaItem, SteamTrade.Inventory.Item inventoryItem, bool id = false) { var currentItem = SteamTrade.Trade.CurrentSchema.GetItem(schemaItem.Defindex); string name = ""; var type = Convert.ToInt32(inventoryItem.Quality.ToString()); if (QualityToName(type) != "Unique") { name += QualityToName(type) + " "; } name += currentItem.ItemName; if (currentItem.CraftMaterialType == "supply_crate") { for (int count = 0; count < inventoryItem.Attributes.Length; count++) { name += " #" + (inventoryItem.Attributes[count].FloatValue); } } name += " (Level " + inventoryItem.Level + ")"; try { int size = inventoryItem.Attributes.Length; for (int count = 0; count < size; count++) { if (inventoryItem.Attributes[count].Defindex == 186) { name += " (Gifted)"; } } } catch { // Item has no attributes... or something. } if (inventoryItem.IsNotCraftable) { name += " (Uncraftable)"; } if (currentItem.Name == "Wrapped Gift") { // Untested! try { int size = inventoryItem.Attributes.Length; for (int count = 0; count < size; count++) { var containedItem = SteamTrade.Trade.CurrentSchema.GetItem(inventoryItem.ContainedItem.Defindex); name += " (Contains: " + containedItem.ItemName + ")"; } } catch { // Item has no attributes... or something. } } if (id) { name += " :" + inventoryItem.Id; } return(name); }