示例#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 string AddInventoryItems(Bot bot, Games game, SteamID steamID, bool img)
        {
            string items = "";

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

            bot.OtherGenericInventory.load((int)game, contextID, steamID);

            if (bot.OtherGenericInventory.errors.Count > 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error while inventory scan :");
                foreach (string error in bot.OtherGenericInventory.errors)
                {
                    Console.WriteLine(error);
                }
                Console.ForegroundColor = ConsoleColor.White;
                items = "EMPTY";
            }
            else
            {
                bool allItemsFound = false;
                while (!allItemsFound)
                {
                    allItemsFound = true;

                    foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);

                        Item i = bot.ArkarrSteamMarket.GetItemByName(description.market_hash_name);
                        if (description.tradable)
                        {
                            if (i != null)// && i.Value != 0)
                            {
                                items += item.assetid + "=" + description.market_hash_name.Replace("|", " - ") + "=" + (i.Value.ToString().Replace(',', '.')) + (img ? "=" + i.Image : "") + ",";
                            }
                            else
                            {
                                items += item.assetid + "=" + description.market_hash_name.Replace("|", " - ") + "=" + "0" + (img ? "=" + "NOT_FOUND" : "") + ",";
                            }
                        }
                    }
                }

                if (items.Length != 0)
                {
                    items = items.Remove(items.Length - 1);
                }
                else
                {
                    items = "EMPTY";
                }
            }

            return(items);
        }
示例#3
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);
        }
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            // USELESS DEBUG MESSAGES -------------------------------------------------------------------------------
            Trade.SendMessage("Object AppID:" + inventoryItem.AppId);

            switch (inventoryItem.AppId)
            {
            case 440:
                Trade.SendMessage("TF2 Item");
                break;

            case 753:
                GenericInventory.ItemDescription tmpDescription = OtherSteamInventory.getInfo(inventoryItem.Id);
                Trade.SendMessage("Object type: " + tmpDescription.type);
                Trade.SendMessage("Marketable: " + tmpDescription.marketable);
                break;

            default:
                Trade.SendMessage("Unknown item");
                break;
            }
            // ------------------------------------------------------------------------------------------------------
        }
示例#5
0
        private void CreateTradeOffer(Bot bot, GameServerRequest gsr)
        {
            float  tradeValue = -1;
            string message    = gsr.Arguments;

            //STEAM_0:1:42047781/2514414967/NULL/999900.00 //TOOOOOOOOO DOOOOOOOOOOOOOO
            string[] assetIDs     = null;
            string[] myAssetIDs   = null;
            string[] steamIDitems = message.Split('/');
            SteamID  steamid      = GetSteamIDFromString(steamIDitems[0]);

            TradeOffer to = bot.TradeOfferManager.NewOffer(steamid);

            GameServer gameServer = bot.Manager.GetServerByID(gsr.ServerID);

            if (steamIDitems[1].Length > 1 && steamIDitems[1] != "NULL")
            {
                assetIDs = steamIDitems[1].Split(',');

                List <long> contextId = new List <long>();
                contextId.Add(2);

                bot.OtherGenericInventory.load((int)Games.CSGO, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
                bot.OtherGenericInventory.load((int)Games.TF2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
                bot.OtherGenericInventory.load((int)Games.Dota2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
            }

            if (steamIDitems[2].Length > 1 && steamIDitems[2] != "NULL")
            {
                myAssetIDs = steamIDitems[2].Split(',');

                List <long> contextId = new List <long>();
                contextId.Add(2);

                bot.MyGenericInventory.load((int)Games.CSGO, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }

                bot.MyGenericInventory.load((int)Games.TF2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }

                bot.MyGenericInventory.load((int)Games.Dota2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
            }

            if (steamIDitems[3] != "NULL")
            {
                tradeValue = float.Parse(steamIDitems[3], CultureInfo.InvariantCulture);
            }

            string offerId;

            to.Send(out offerId, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm")));

            if (offerId != "")
            {
                bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, offerId);
                bot.TradeoffersGS.Add(offerId, gsr.ModuleID + "|" + tradeValue);
                bot.TradeOfferValue.Add(offerId, tradeValue);

                bot.AcceptMobileTradeConfirmation(offerId);
            }
            else
            {
                bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, "-1");
            }
        }
示例#6
0
        public void WithDrawn(string steamid)
        {
            SteamID steamID = new SteamID(steamid);

            if (!friends.Contains(steamID))
            {
                Console.WriteLine("This user is not in your friend list, unable to send trade offer.");
                return;
            }

            string name = SteamFriends.GetFriendPersonaName(steamID);

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("You are about to send ALL the bot's items to");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(" {0} ({1}) ", name, steamid);
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("via a trade offer, do you confirm ? (YES / NO)");
            Console.WriteLine();
            string answer = Console.ReadLine();

            if (!answer.Equals("YES"))
            {
                Console.WriteLine("Operation cancelled. Nothing traded.");
                return;
            }

            TradeOffer to = tradeOfferManager.NewOffer(steamID);

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

            MyGenericInventory.load((int)Games.TF2, contextID, steamUser.SteamID);
            foreach (GenericInventory.Item item in MyGenericInventory.items.Values)
            {
                GenericInventory.ItemDescription description = MyGenericInventory.getDescription(item.assetid);
                if (description.tradable)
                {
                    to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                }
            }

            MyGenericInventory.load((int)Games.CSGO, contextID, steamUser.SteamID);
            foreach (GenericInventory.Item item in MyGenericInventory.items.Values)
            {
                GenericInventory.ItemDescription description = MyGenericInventory.getDescription(item.assetid);
                if (description.tradable)
                {
                    to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                }
            }

            MyGenericInventory.load((int)Games.Dota2, contextID, steamUser.SteamID);
            foreach (GenericInventory.Item item in MyGenericInventory.items.Values)
            {
                GenericInventory.ItemDescription description = MyGenericInventory.getDescription(item.assetid);
                if (description.tradable)
                {
                    to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                }
            }

            if (to.Items.GetMyItems().Count <= 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Couldn't send trade offer, inventory is empty.");
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                string offerId;
                to.Send(out offerId, "Backpack withdrawn");

                AcceptMobileTradeConfirmation(offerId);

                Console.WriteLine("Whitdrawn offer sent !");
            }
        }
        private void CreateTradeOffer(Bot bot, GameServerRequest gsr)
        {
            float  tradeValue = -1;
            string message    = gsr.Arguments;

            string[] assetIDs     = null;
            string[] myAssetIDs   = null;
            string[] steamIDitems = message.Split('/');
            SteamID  steamid      = GetSteamIDFromString(steamIDitems[0]);

            if (!steamid.IsValid)
            {
                return;
            }

            TradeOffer to = bot.TradeOfferManager.NewOffer(steamid);

            GameServer gameServer = bot.Manager.GetServerByID(gsr.ServerID);

            if (steamIDitems[1].Length > 1 && steamIDitems[1] != "NULL")
            {
                assetIDs = steamIDitems[1].Split(',');

                List <long> contextId = new List <long>();
                contextId.Add(2);

                bot.OtherGenericInventory.load((int)Games.CSGO, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
                bot.OtherGenericInventory.load((int)Games.TF2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
                bot.OtherGenericInventory.load((int)Games.Dota2, contextId, steamid);

                foreach (GenericInventory.Item item in bot.OtherGenericInventory.items.Values)
                {
                    if (Array.IndexOf(assetIDs, item.assetid.ToString()) > -1)
                    {
                        GenericInventory.ItemDescription description = (ItemDescription)bot.OtherGenericInventory.getDescription(item.assetid);
                        to.Items.AddTheirItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
            }

            if (steamIDitems[2].Length > 1 && steamIDitems[2] != "NULL")
            {
                myAssetIDs = steamIDitems[2].Split(',');

                List <long> contextId = new List <long>();
                contextId.Add(2);

                bot.MyGenericInventory.load((int)Games.CSGO, contextId, bot.getSteamID());

                foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid);
                        to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }

                bot.MyGenericInventory.load((int)Games.TF2, contextId, bot.getSteamID());

                foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid);
                        to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }

                bot.MyGenericInventory.load((int)Games.Dota2, contextId, bot.getSteamID());

                foreach (GenericInventory.Item item in bot.MyGenericInventory.items.Values)
                {
                    if (Array.IndexOf(myAssetIDs, item.assetid.ToString()) > -1)
                    {
                        ItemDescription description = (ItemDescription)bot.MyGenericInventory.getDescription(item.assetid);
                        to.Items.AddMyItem(item.appid, item.contextid, (long)item.assetid);
                    }
                }
            }

            if (steamIDitems[3] != "NULL")
            {
                tradeValue = float.Parse(steamIDitems[3], CultureInfo.InvariantCulture);
            }

            string offerId = "";

            string token = bot.GetToken(steamid);

            if (bot.Friends.Contains(steamid.ConvertToUInt64()))
            {
                to.Send(out offerId, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm")));
            }
            else if (token != null)
            {
                to.SendWithToken(out offerId, token, String.Format("\"{0}\" the {1}@{2}", gameServer.Name, DateTime.Now.ToString("dd/MM/yyyy"), DateTime.Now.ToString("HH:mm")));
            }
            else
            {
                bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, steamid.ConvertToUInt64().ToString() + "/" + "trade_token_not_found");
            }

            if (offerId != "")
            {
                bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, steamid.ConvertToUInt64() + "/" + offerId);
                bot.TradeoffersGS.Add(offerId, gsr.ServerID + "|" + gsr.ModuleID + "|" + tradeValue);
                bot.TradeOfferValue.Add(offerId, tradeValue);

                bot.AcceptMobileTradeConfirmation(offerId);

                bot.UpdateTradeOfferInDatabase(to, tradeValue);
            }
            else
            {
                if (token != null)
                {
                    bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.TradeToken, steamid.ConvertToUInt64().ToString() + "/" + "trade_token_invalid");
                }

                bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.CreateTradeOffer, steamid.ConvertToUInt64() + "/" + "-1");
            }
        }