示例#1
0
        public override void OnTradeInit()
        {
            // NEW -------------------------------------------------------------------------------
            List <long> contextId = new List <long>();

            tested = false;

            /*************************************************************************************
             *
             * SteamInventory AppId = 753
             *
             *  Context Id      Description
             *      1           Gifts (Games), must be public on steam profile in order to work.
             *      6           Trading Cards, Emoticons & Backgrounds.
             *
             ************************************************************************************/

            contextId.Add(1);
            contextId.Add(6);

            mySteamInventory.load(753, contextId, Bot.SteamClient.SteamID);
            OtherSteamInventory.load(753, contextId, OtherSID);

            if (!mySteamInventory.isLoaded | !OtherSteamInventory.isLoaded)
            {
                SendTradeMessage("Couldn't open an inventory, type 'errors' for more info.");
            }

            SendTradeMessage("Type 'test' to start.");
            // -----------------------------------------------------------------------------------
        }
        public override void OnTradeInit()
        {
            // NEW -------------------------------------------------------------------------------
            List <uint> InvType = new List <uint>();

            /*************************************************************************************
             *
             * SteamInventory AppId = 753
             *
             * Inventory types:
             *  1 = Gifts (Games), must be public on steam profile in order to work.
             *  6 = Trading Cards, Emoticons & Backgrounds.
             *
             ************************************************************************************/

            InvType.Add(1);
            InvType.Add(6);

            mySteamInventory.load(753, InvType, Bot.SteamClient.SteamID);
            OtherSteamInventory.load(753, InvType, OtherSID);

            if (!OtherSteamInventory.loaded)
            {
                Trade.SendMessage("Couldn't open your inventory, type 'errors' for more info.");
            }

            // -----------------------------------------------------------------------------------
        }
示例#3
0
 public void InventoryFetcher()
 {
     while (!WaitingForRestart)
     {
         GenericInventory inv = new GenericInventory(bot.SteamWeb);
         inv.load(730, new long[] { 2 }, bot.SteamUser.SteamID, "russian");
         int counter = inv.descriptions.Count;
         if (counter != 0)   //lol...
         {
             logic.cachedInventory     = inv;
             logic.cachedTradableCount = counter;
             LocalRequest.PutInventory(config.Username, inv);
             double tradeprice = 0;
             int    untracked  = 0;
             logic.__database__.EnterReadLock();
             try {
                 double medianprice = 0;
                 foreach (var item in inv.descriptions)
                 {
                     string quality;
                     string runame;
                     try {
                         quality = item.Value.market_hash_name.Split(new char[] { '(', ')' })[1];
                         runame  = item.Value.name + " (" + ConvertQualityToRussian(quality) + ")";
                     } catch {
                         runame = item.Value.name;
                         //???
                         continue;
                     }
                     if (logic.__database__.newDataBase.TryGetValue(runame, out Logic.BasicSalesHistory sales))
                     {
                         int medPrice = sales.GetMedian();
                         medianprice += medPrice;
                         if (item.Value.tradable)
                         {
                             tradeprice += medPrice;
                         }
                     }
                 }
                 LocalRequest.PutTradableCost(config.Username, Economy.ConvertCurrency(Economy.Currency.RUB, Economy.Currency.USD, tradeprice / 100), untracked);
                 LocalRequest.PutMedianCost(config.Username, Economy.ConvertCurrency(Economy.Currency.RUB, Economy.Currency.USD, medianprice / 100));
             } finally {
                 logic.__database__.ExitReadLock();
             }
         }
         LocalRequest.PutMoney(config.Username, protocol.GetMoney());
         if (counter != 0)
         {
             Tasking.WaitForFalseOrTimeout(IsRunning, timeout: Consts.MINORCYCLETIMEINTERVAL).Wait(); //10 minutes this data is pretty much static
         }
         else
         {
             Tasking.WaitForFalseOrTimeout(IsRunning, timeout: Consts.MINORCYCLETIMEINTERVAL / 10).Wait(); //1 minute because I need to reupload inventory on failure.
         }
     }
 }
示例#4
0
        private double GetTradeOfferValue(SteamID partenar, List <TradeOffer.TradeStatusUser.TradeAsset> list)
        {
            if (list.Count > 0)
            {
                Console.WriteLine(list.Count);
            }

            double cent = 0;

            long[] contextID = new long[1];
            contextID[0] = 2;

            List <long>      appIDs = new List <long>();
            GenericInventory gi     = new GenericInventory(steamWeb);

            foreach (TradeOffer.TradeStatusUser.TradeAsset item in list)
            {
                if (!appIDs.Contains(item.AppId))
                {
                    appIDs.Add(item.AppId);
                }
            }

            foreach (int appID in appIDs)
            {
                gi.load(appID, contextID, partenar);
                foreach (TradeOffer.TradeStatusUser.TradeAsset item in list)
                {
                    if (item.AppId != appID)
                    {
                        continue;
                    }

                    GenericInventory.ItemDescription ides = gi.getDescription((ulong)item.AssetId);

                    SteamMarketPrices.Item itemInfo = smp.Items.Find(i => i.name == ides.market_hash_name);
                    if (itemInfo != null)
                    {
                        cent += (itemInfo.value / 100.0);
                    }
                    else
                    {
                        Console.WriteLine("Item " + ides.market_hash_name + " not found !");
                    }
                }
            }

            return(cent);
        }
        private void OnNewTradeOffer(TradeOffer offer)
        {
            var myItems    = offer.Items.GetMyItems();
            var theirItems = offer.Items.GetTheirItems();

            if (myItems.Count == 0)
            {
                offer.Accept();
                Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "I received a donation offer!");
                Bot.AcceptAllMobileTradeConfirmations();
                Log.Success("Received a donation-offer");
            }
            else
            {
                Bot.TradeOfferEscrowDuration CurrentEscrow = Bot.GetEscrowDuration(offer.TradeOfferId);

                //Check if trader has delayed trades
                if (CurrentEscrow.DaysTheirEscrow > 2)
                {
                    Log.Error("Trade offer has been declined due to escrow.");
                    Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "Incoming trade offer has been declined due to escrow.");
                    offer.Decline();
                }
                else
                {
                    List <long> contextId = new List <long>();
                    contextId.Add(2);
                    contextId.Add(6);

                    mySteamInventory.load(440, contextId, Bot.SteamClient.SteamID);
                    OtherSteamInventory.load(440, contextId, offer.PartnerSteamId);

                    int MyRef = 0;
                    int MyKey = 0;

                    int TheirRef = 0;
                    int TheirKey = 0;

                    #region User
                    for (int count = 0; count < theirItems.Count; count++)
                    {
                        if (theirItems[count].AppId == 440)
                        {
                            if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Scrap Metal")
                            {
                                TheirRef += 1;
                            }
                            else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Reclaimed Metal")
                            {
                                TheirRef += 3;
                            }
                            else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Refined Metal")
                            {
                                TheirRef += 9;
                            }
                            else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Mann Co. Supply Crate Key")
                            {
                                TheirKey++;
                            }
                        }
                    }
                    #endregion
                    #region Bot
                    for (int count = 0; count < myItems.Count; count++)
                    {
                        if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Scrap Metal")
                        {
                            MyRef += 1;
                        }
                        else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Reclaimed Metal")
                        {
                            MyRef += 3;
                        }
                        else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Refined Metal")
                        {
                            MyRef += 9;
                        }
                        else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Mann Co. Supply Crate Key")
                        {
                            MyRef += 9;
                        }
                    }
                    #endregion
                    #region Calculate
                    Console.Write(" - TheirKey: " + TheirKey);
                    Console.Write(" - Buyprice: " + buyPrice);
                    Console.WriteLine(" - MyRef: " + MyRef);
                    Console.Write(" - MyKey: " + MyKey);
                    Console.Write(" - SellPrice: " + sellPrice);
                    Console.WriteLine(" - TheirRef: " + TheirRef);
                    if (((TheirKey * buyPrice) == MyRef) && ((MyKey * sellPrice) == TheirRef))
                    {
                        Log.Success("[#" + offer.TradeOfferId + "] Accepted Offer.");
                        offer.Accept();
                        Bot.AcceptAllMobileTradeConfirmations();
                        Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "I've done a succesful offer with " + Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId) + ".");
                    }
                    else if (IsAdmin)
                    {
                        string tradeid;
                        offer.Accept(out tradeid);
                        Log.Success("[ADMINOFFER] Accepted trade offer successfully : Trade ID: " + tradeid);
                        Bot.AcceptAllMobileTradeConfirmations();
                    }
                    else
                    {
                        Log.Success("[#" + offer.TradeOfferId + "] Declined Offer.");
                        offer.Decline();
                        Bot.AcceptAllMobileTradeConfirmations();
                    }
                    #endregion
                }
            }
        }