Ejemplo n.º 1
0
        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            using (var db = new Database())
            {
                if (args.Length < 2)
                {
                    player.SendError("Usage: /sell <slot> <price>");
                    return(false);
                }
                if (Convert.ToInt32(args[0]) > 8 || Convert.ToInt32(args[0]) < 1)
                {
                    player.SendError("Slot Number Invalid, please only choose items in slot 1-8");
                    return(false);
                }
                if (Convert.ToInt32(args[1]) < 0)
                {
                    player.SendError("Fame must be more than 0");
                    return(false);
                }
                int  slot = Convert.ToInt32(args[0]) + 3;
                Item item = player.Inventory[slot];

                if (Merchant.checkItem(player.Inventory[slot]))
                {
                    MySqlCommand cmd = db.CreateQuery();
                    cmd.CommandText = "INSERT INTO market(itemID, fame, playerid) VALUES(@itemID, @fame, @playerID)";
                    cmd.Parameters.AddWithValue("@itemID", Convert.ToInt32(item.ObjectType));
                    cmd.Parameters.AddWithValue("@fame", args[1]);
                    var plr = player.Manager.FindPlayer(player.Name);
                    cmd.Parameters.AddWithValue("@playerID", plr.AccountId);
                    try
                    {
                        cmd.ExecuteNonQuery();
                        player.Inventory[slot] = null;
                        player.Client.Save();
                        player.UpdateCount++;
                        MerchantLists.AddItem(item, Convert.ToInt32(args[1]));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[" + DateTime.Now.ToString("h:mm:ss tt") + "] " + e);
                    }
                    return(true);
                }
            }
            player.SendError("You cannot sell this item!");
            return(false);
        }
Ejemplo n.º 2
0
        protected override Tuple <bool, string> Process(Player player, RealmTime time, string[] args)
        {
            using (var db = new Database())
            {
                if (args.Length < 2)
                {
                    return(Tuple.Create(false, "Usage: /sell <slot> <price>"));
                }

                int slot = Convert.ToInt32(args[0]) + 3;
                if (slot > 11 || slot < 4)
                {
                    return(Tuple.Create(false, "Slot Number Invalid, please only choose items in slot 1-8"));
                }

                if (Convert.ToInt32(args[1]) < 0)
                {
                    return(Tuple.Create(false, "Selling price must be a positive integer"));
                }

                Item item = player.Inventory[slot];
                if (item.Secret || item.Soulbound)
                {
                    return(Tuple.Create(false, $"Cannot Sell {item.ObjectId} because it is soulbound or secret"));
                }

                if (Merchant.checkItem(player.SerialConvert(player.Inventory[slot])))
                {
                    MySqlCommand cmd = db.CreateQuery();
                    cmd.CommandText = "INSERT INTO market(itemID, fame, serialid) VALUES(@itemID, @fame, @serialid)";
                    cmd.Parameters.AddWithValue("@itemID", Convert.ToInt32(item.ObjectType));
                    cmd.Parameters.AddWithValue("@fame", args[1]);
                    cmd.Parameters.AddWithValue("@serialid", item.serialId);
                    cmd.ExecuteNonQuery();
                    player.Inventory[slot] = null;
                    player.Client.Save();
                    player.UpdateCount++;
                    MerchantLists.AddItem(item, Convert.ToInt32(args[1])); //Adds to runtime
                    return(Tuple.Create(true, "Success"));
                }
                return(Tuple.Create(false, $"Cannot Sell {item.ObjectId}"));
            }
        }