public void LoadOffers() { Offers = new Dictionary<int, MarketOffer>(); DataTable Table = null; using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("SELECT MAX(id) FROM marketplace_offers LIMIT 1"); OfferIdCounter = new SecurityCounter(Reactor.GetInt32()); } using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("SELECT * FROM marketplace_offers"); Table = Reactor.GetTable(); } foreach (DataRow Row in Table.Rows) { MarketOffer Offer = new MarketOffer(Row); Offers.Add(Offer.Id, Offer); } BrickEngine.GetScreenWriter().ScretchLine("[" + Offers.Count + "] MarketplaceOffer(s) cached.", IO.WriteType.Outgoing); }
public void InsertOffer(Client Client, Item Item, int GeneralPrice) { Response Response = new Response(610); // Verifying. if (GeneralPrice > 10000 || !Item.GetBaseItem().EnableAuction) { Response.AppendBoolean(false); Client.SendResponse(Response); return; } // OfferDetails int OfferId = OfferIdCounter.Next; // Developmentdetails int DevelopmentId = DevelopmentIdCounter.Next; // Both details int TotalPrice = (GeneralPrice + GetPriceCommission(GeneralPrice)); DateTime DateTime = DateTime.Now; // Generating offer, and adding offer Dictionary<int, Object> OfferRow = new Dictionary<int, object>(); OfferRow[0] = OfferId; OfferRow[1] = Client.GetUser().HabboId; OfferRow[2] = Item.BaseId; OfferRow[3] = 1; OfferRow[4] = Item.GetBaseItem().InternalName.ToLower(); OfferRow[5] = GeneralPrice; OfferRow[6] = TotalPrice; OfferRow[7] = DateTime; // Generating from leak-row MarketOffer Offer = new MarketOffer(OfferRow); Offers.Add(Offer.Id, Offer); // Generating development, and adding development Dictionary<int, Object> DevelopmentRow = new Dictionary<int, object>(); DevelopmentRow[0] = DevelopmentId; DevelopmentRow[1] = Item.BaseId; DevelopmentRow[2] = DateTime; DevelopmentRow[3] = TotalPrice; // Generating from leak-row MarketDevelopment Development = new MarketDevelopment(DevelopmentRow); Developments.Add(Development.Id, Development); // Sending positive response Response.AppendBoolean(true); Client.SendResponse(Response); // Delete furniture @ cache + response update Client.SendResponse(BrickEngine.GetItemReactor().RemoveItem(Item.Id)); // Delete furniture @ database using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("DELETE FROM items WHERE id = @itemid LIMIT 1"); Reactor.AddParam("itemid", Item.Id); Reactor.ExcuteQuery(); } // Insert Offer @ database using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("INSERT INTO marketplace_offers (user_id, base_id, base_name, credits_request, credits_request_tot, datetime) VALUES (@habboid, @baseid, @basename, @creditsreq, @creditsreqtot, @datetime)"); Reactor.AddParam("habboid", Client.GetUser().HabboId); Reactor.AddParam("baseid", Item.BaseId); Reactor.AddParam("basename", Item.GetBaseItem().InternalName.ToLower()); Reactor.AddParam("creditsreq", GeneralPrice); Reactor.AddParam("creditsreqtot", TotalPrice); Reactor.AddParam("datetime", DateTime); Reactor.ExcuteQuery(); } // Insert Development @ database using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("INSERT INTO marketplace_development (base_id, datetime, credits_request) VALUES (@baseid, @datetime, @creditsreq)"); Reactor.AddParam("baseid", Item.BaseId); Reactor.AddParam("datetime", DateTime); Reactor.AddParam("creditsreq", TotalPrice); Reactor.ExcuteQuery(); } // Update tickets @ cache Client.GetUser().MarketplaceTickets--; // Update tickets @ database using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("UPDATE users SET marketplace_tickets = marketplace_tickets - 1 WHERE id = @habboid LIMIT 1"); Reactor.AddParam("habboid", Client.GetUser().HabboId); Reactor.ExcuteQuery(); } }