コード例 #1
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            // USELESS DEBUG MESSAGES -------------------------------------------------------------------------------
            SendTradeMessage("Object AppID: {0}", inventoryItem.AppId);
            SendTradeMessage("Object ContextId: {0}", inventoryItem.ContextId);

            switch (inventoryItem.AppId)
            {
            case 440:
                SendTradeMessage("TF2 Item Added.");
                SendTradeMessage("Name: {0}", schemaItem.Name);
                SendTradeMessage("Quality: {0}", inventoryItem.Quality);
                SendTradeMessage("Level: {0}", inventoryItem.Level);
                SendTradeMessage("Craftable: {0}", (inventoryItem.IsNotCraftable ? "No" : "Yes"));
                break;

            case 753:
                GenericInventory.ItemDescription tmpDescription = OtherSteamInventory.getDescription(inventoryItem.Id);
                SendTradeMessage("Steam Inventory Item Added.");
                SendTradeMessage("Type: {0}", tmpDescription.type);
                SendTradeMessage("Marketable: {0}", (tmpDescription.marketable ? "Yes" : "No"));
                break;

            default:
                SendTradeMessage("Unknown item");
                break;
            }
            // ------------------------------------------------------------------------------------------------------
        }
コード例 #2
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);
        }
コード例 #3
0
        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
                }
            }
        }