internal void MarketplacePurchase() { uint ItemId = Request.PopWiredUInt(); DataRow Row = null; using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT state, timestamp, total_price, extra_data, item_id FROM catalog_marketplace_offers WHERE offer_id = " + ItemId + " "); Row = dbClient.getRow(); } if (Row == null || (string)Row["state"] != "1" || (double)Row["timestamp"] < OtanixEnvironment.GetUnixTimestamp()) { Session.SendNotif(LanguageLocale.GetValue("catalog.offerexpired")); return; } uint prize = Convert.ToUInt32(Row["total_price"]); if (prize < 2 || Session.GetHabbo().Diamonds < prize) { Session.SendNotif(LanguageLocale.GetValue("catalog.crystalerror")); return; } var Item = OtanixEnvironment.GetGame().GetItemManager().GetItem(Convert.ToUInt32(Row["item_id"])); if (Item == null) { return; } List <UserItem> items = OtanixEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (String)Row["extra_data"], false, 0); if (items.Count == 0) { return; } Session.GetHabbo().Diamonds -= prize; Session.GetHabbo().UpdateExtraMoneyBalance(); using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("UPDATE catalog_marketplace_offers SET state = 2 WHERE offer_id = " + ItemId + ""); Marketplace.AddItemToStatistics(Item.ItemId, prize, dbClient); } Session.GetMessageHandler().GetResponse().Init(Outgoing.MarketBuyItem); Session.GetMessageHandler().GetResponse().AppendInt32(1); // result (1,2,3,4) Session.GetMessageHandler().GetResponse().AppendUInt(items[0].Id); // Session.GetMessageHandler().GetResponse().AppendUInt(prize); // Session.GetMessageHandler().GetResponse().AppendUInt(ItemId); Session.GetMessageHandler().SendResponse(); Session.GetMessageHandler().GetResponse().Init(Outgoing.SendPurchaseAlert); Session.GetMessageHandler().GetResponse().AppendInt32(1); // items Session.GetMessageHandler().GetResponse().AppendInt32(1); Session.GetMessageHandler().GetResponse().AppendInt32(1); Session.GetMessageHandler().GetResponse().AppendUInt(items[0].Id); Session.GetMessageHandler().SendResponse(); if (Session != null && Session.GetHabbo() != null && Session.GetHabbo().GetInventoryComponent() != null) { Session.GetHabbo().GetInventoryComponent().UpdateItems(false); } }