public void LoadClothes() { Clothes = new Dictionary<int, Dictionary<int, Clothe>>(); DataTable Table = null; using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("SELECT * FROM user_clothes ORDER BY slot_id ASC"); Table = Reactor.GetTable(); } if (Table != null) { foreach(DataRow Row in Table.Rows) { Clothe Clothe = new Clothe(Row); if (!Clothes.ContainsKey(Clothe.HabboId)) { Clothes.Add(Clothe.HabboId, new Dictionary<int, Clothe>()); } if (!Clothes[Clothe.HabboId].ContainsKey(Clothe.SlotId) && Clothe.SlotId >= 1 && Clothe.SlotId <= 10) { Clothes[Clothe.HabboId].Add(Clothe.SlotId, Clothe); } } } BrickEngine.GetScreenWriter().ScretchLine("[" + Table.Rows.Count + "] ClotheCache(s) cached.", IO.WriteType.Outgoing); }
private void UpdateClothe(Client Client, Request Request) { Membership Membership = Client.GetUser().GetMembership(); if (Membership == null) { return; } int SlotId = Request.PopWiredInt32(); string Look = BrickEngine.CleanString(Request.PopFixedString()); string Gender = BrickEngine.CleanString(Request.PopFixedString()); var LeakedRow = new Dictionary<int, Object>(); SecurityCounter Counter = new Security.SecurityCounter(-1); LeakedRow[Counter.Next] = Client.GetUser().HabboId; LeakedRow[Counter.Next] = SlotId; LeakedRow[Counter.Next] = Look; LeakedRow[Counter.Next] = Gender; Clothe LeakedClothe = new Clothe(LeakedRow); BrickEngine.GetClothesHandler().UpdateClothe(LeakedClothe.HabboId, LeakedClothe); }
public void UpdateClothe(int HabboId, Clothe Clothe) { if (!Clothes.ContainsKey(HabboId)) { Clothes.Add(HabboId, new Dictionary<int, Clothe>()); } if (!Clothes[HabboId].ContainsKey(Clothe.SlotId)) { Clothes[HabboId].Add(Clothe.SlotId, Clothe); using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("INSERT INTO user_clothes (user_id, slot_id, look, gender) VALUES (@habboid, @slotid, @look, @gender)"); Reactor.AddParam("look", Clothe.Look); Reactor.AddParam("gender", Clothe.Gender); Reactor.AddParam("habboid", HabboId); Reactor.AddParam("slotid", Clothe.SlotId); Reactor.ExcuteQuery(); } } else { Clothes[HabboId][Clothe.SlotId] = Clothe; using (QueryReactor Reactor = BrickEngine.GetQueryReactor()) { Reactor.SetQuery("UPDATE user_clothes SET look = @look, gender = @gender WHERE user_id = @habboid AND slot_id = @slotid LIMIT 1"); Reactor.AddParam("look", Clothe.Look); Reactor.AddParam("gender", Clothe.Gender); Reactor.AddParam("habboid", HabboId); Reactor.AddParam("slotid", Clothe.SlotId); Reactor.ExcuteQuery(); } } }