public async Task CSell(GSSession session, CSell message) { if (session.Player.Window == null) { throw new ArgumentException("Player isn't in buy/trade/box", nameof(session.Player.Window)); } if (session.Player.Window.GetType() != typeof(Storage)) { throw new ArgumentException("Player isn't in buy", nameof(session.Player.Window)); } var shop = session.Player.Window as Storage; var inve = session.Player.Character.Inventory; var item = inve.Get(message.Position); inve.Remove(message.Position); session.Player.Character.Money += item.SellPrice; var result = new SSell { Result = 1, Money = session.Player.Character.Money }; await session.SendAsync(result); }
public void OnSellClicked() { CSell sell = new CSell(); sell.to_sell = Attribute.apply; sell.to_sell_price = FMarket.all_silver_price[sell.to_sell] / 2; Client.Instance.Send(sell); }
private void OnRecvSell(IChannel channel, Message message) { CSell request = message as CSell; //SPlayerAttribute response = new SPlayerAttribute(); //SGetInventory response2 = new SGetInventory(); Player player = (Player)channel.GetContent(); int flag = 0; Console.WriteLine(request.to_sell); if (request.to_sell != player.attack_item && request.to_sell != player.defense_item && request.to_sell != player.speed_item && request.to_sell != player.inteligence_item) { Console.WriteLine("Adding"); flag = 1; } var connString = "Host=localhost;Port=5432;Username=postgres;Password=123456;Database=postgres"; var sqlstring = ""; var item_id = ""; var sqlstring2 = ""; sqlstring2 = string.Format("SELECT COUNT(*) FROM worldmarket WHERE seller='{0}'", player.user); var conn2 = new NpgsqlConnection(connString); conn2.Open(); var cmd2 = new NpgsqlCommand(sqlstring2, conn2); var reader2 = cmd2.ExecuteReader(); reader2.Read(); int count = reader2.GetInt16(0); reader2.Close(); var sqlstring3 = ""; int user_selling_items = count + 1; Console.WriteLine(user_selling_items); if (flag == 1) { item_id = string.Format("{0}_{1}", player.user, user_selling_items); Console.WriteLine(item_id); sqlstring = string.Format("INSERT INTO worldmarket VALUES ('{0}','{1}','{2}',{3},0);", item_id, request.to_sell, player.user, request.to_sell_price); var conn = new NpgsqlConnection(connString); conn.Open(); var cmd = new NpgsqlCommand(sqlstring, conn); var reader = cmd.ExecuteReader(); reader.Read(); reader.Close(); sqlstring3 = string.Format("UPDATE users_items SET item_num=item_num-1 WHERE user_name = '{0}'and item_name='{1}';", player.user, request.to_sell); var conn3 = new NpgsqlConnection(connString); conn3.Open(); var cmd3 = new NpgsqlCommand(sqlstring3, conn3); var reader3 = cmd3.ExecuteReader(); reader3.Read(); reader3.Close(); ClientTipInfo(channel, "Added to worldmarket"); } if (flag == 0) { ClientTipInfo(channel, "Unapply first"); } }