private void goButton_Click(object sender, EventArgs e)
 {
     itemLB.DataSource = null;
     loadedInventory = new Inventory(Convert.ToUInt64(steamIdNUD.Value), Convert.ToUInt32(appIdNUD.Value));
     items.Clear();
     List<string> l1 = new List<string>();
     foreach(Item i in loadedInventory.Items.Values)
     {
         if(!items.ContainsKey(i.Description.MarketHashName))
             items.Add(i.Description.MarketHashName, i);
     }
     itemLB.DataSource = items.Keys.ToList();
     itemLB.Refresh();
 }
Пример #2
0
        private static void PollOffers()
        {
            Console.WriteLine("Polling offers every ten seconds.");

            bool isPolling = true;

            var offerHandler = new EconServiceHandler(_config.ApiKey);
            var marketHandler = new MarketHandler();

            Inventory csgoInventory = new Inventory(_account.SteamId, 730);

            marketHandler.EligibilityCheck(_account.SteamId, _account.AuthContainer);
            //required to perform trades (?). Checks to see whether or not we're allowed to trade.

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            // ReSharper disable once LoopVariableIsNeverChangedInsideLoop
            while (isPolling) //permanent loop, can be changed
            {
                Thread.Sleep(10000);

                var recData = new Dictionary<string, string>
                {
                    {"get_received_offers", "1"},
                    {"active_only", "1"},
                    {"time_historical_cutoff", "999999999999"}
                    //arbitrarily high number to retrieve latest offers
                };

                var offers = offerHandler.GetTradeOffers(recData).TradeOffersReceived;

                if (offers == null) continue;

                foreach (CEconTradeOffer cEconTradeOffer in offers)
                {
                    TradeOffer offer = new TradeOffer();
                    offer.Them.Assets = cEconTradeOffer.ItemsToReceive;
                    offer.Me.Assets.Add(csgoInventory.Items.First().Value.Items.First().ToCEconAsset(730));
                    offerHandler.ModifyTradeOffer(IdConversions.AccountIdToUlong(cEconTradeOffer.AccountIdOther),
                        "Here you go!", "1", cEconTradeOffer.TradeOfferId, offer, _account.AuthContainer);
                }
            }
        }
 /// <summary>
 /// Locates an Item in the inventory.
 /// </summary>
 /// <param name="assetToFind">Specifies search params.</param>
 /// <param name="inv">Inventory to search.providing the </param>
 /// <returns></returns>
 public Item FindUnusedItem(CEconAsset assetToFind, Inventory inv)
 {
     //Inventory inv = Inventories[Convert.ToUInt32(assetToFind.appid)];
     return inv.Items[assetToFind.ClassId];
 }