public Trade(uint UserOneId, uint UserTwoId, uint RoomId) { this.oneId = UserOneId; this.twoId = UserTwoId; this.Users = new List<TradeUser>(2); this.Users.Add(new TradeUser(UserOneId, RoomId)); this.Users.Add(new TradeUser(UserTwoId, RoomId)); this.TradeStage = 1; this.RoomId = RoomId; foreach (TradeUser User in Users) { if (!User.GetRoomUser().Statusses.ContainsKey("trd")) { User.GetRoomUser().AddStatus("trd", ""); User.GetRoomUser().UpdateNeeded = true; } } ServerPacket Message = new ServerPacket(104); Message.AppendUInt(UserOneId); Message.AppendBoolean(true); Message.AppendUInt(UserTwoId); Message.AppendBoolean(true); SendMessageToUsers(Message); }
public void parse(GameClient Session, ClientPacket Packet) { CatalogPage Page = UberEnvironment.GetGame().GetCatalog().GetPage(Packet.PopWiredInt32()); if (Page == null || !Page.Enabled || !Page.Visible || Page.ComingSoon || Page.MinRank > Session.GetHabbo().Rank) { return; } if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) { Session.SendNotif("This page is for Club members only!"); return; } Session.SendPacket(UberEnvironment.GetGame().GetCatalog().SerializePage(Page)); if (Page.Layout == "recycler") { ServerPacket message = new ServerPacket(507); message.AppendBoolean(true); message.AppendBoolean(false); Session.SendPacket(message); } }
public void parse(GameClient Session, ClientPacket Packet) { ServerPacket packet = new ServerPacket(611); packet.AppendBoolean(true); packet.AppendInt32(99999); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { uint _id = Packet.PopWiredUInt(); DataRow Row = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Row = dbClient.ReadDataRow("SELECT * FROM catalog_marketplace_offers WHERE offer_id = '" + _id + "' LIMIT 1"); } if (Row == null || (uint)Row["user_id"] != Session.GetHabbo().Id || (string)Row["state"] != "1") { return; } Item Item = UberEnvironment.GetGame().GetItemManager().GetItem((uint)Row["item_id"]); if (Item == null) { return; } UberEnvironment.GetGame().GetCatalog().DeliverItems(Session, Item, 1, (string)Row["extra_data"]); using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.ExecuteQuery("DELETE FROM catalog_marketplace_offers WHERE offer_id = '" + _id + "' LIMIT 1"); } ServerPacket packet = new ServerPacket(614); packet.AppendUInt((uint)Row["offer_id"]); packet.AppendBoolean(true); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { uint Id = Packet.PopWiredUInt(); RoomData Data = UberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Id); if (Data == null || Session.GetHabbo().FavoriteRooms.Count >= 30 || Session.GetHabbo().FavoriteRooms.Contains(Id) || Data.Type == "public") { ServerPacket packet = new ServerPacket(33); packet.AppendInt32(-9001); Session.SendPacket(packet); return; } ServerPacket _packet = new ServerPacket(459); _packet.AppendUInt(Id); _packet.AppendBoolean(true); Session.SendPacket(_packet); Session.GetHabbo().FavoriteRooms.Add(Id); using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.ExecuteQuery("INSERT INTO user_favorites (user_id,room_id) VALUES ('" + Session.GetHabbo().Id + "','" + Id + "')"); } }
public void parse(GameClient Session, ClientPacket Packet) { ServerPacket packet = new ServerPacket(267); packet.AppendBoolean(Session.GetHabbo().HasFuse("fuse_use_wardrobe")); if (Session.GetHabbo().HasFuse("fuse_use_wardrobe")) { DataTable WardrobeData = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("userid", Session.GetHabbo().Id); WardrobeData = dbClient.ReadDataTable("SELECT * FROM user_wardrobe WHERE user_id = @userid"); } if (WardrobeData == null) { packet.AppendInt32(0); } else { packet.AppendInt32(WardrobeData.Rows.Count); foreach (DataRow Row in WardrobeData.Rows) { packet.AppendUInt((uint)Row["slot_id"]); packet.AppendStringWithBreak((string)Row["look"]); packet.AppendStringWithBreak((string)Row["gender"]); } } } Session.SendPacket(packet); }
public void SellItem(GameClient Session, uint ItemId, int SellingPrice) { UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId); if (Item == null || SellingPrice > 10000 || !CanSellItem(Item)) { ServerPacket packet = new ServerPacket(610); packet.AppendBoolean(false); Session.SendPacket(packet); return; } int Comission = CalculateComissionPrice(SellingPrice); int TotalPrice = SellingPrice + Comission; int ItemType = 1; if (Item.GetBaseItem().Type == "i") { ItemType++; } using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("public_name", Item.GetBaseItem().PublicName); dbClient.AddParamWithValue("extra_data", Item.ExtraData); dbClient.ExecuteQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES ('" + Item.BaseItem + "','" + Session.GetHabbo().Id + "','" + SellingPrice + "','" + TotalPrice + "',@public_name,'" + Item.GetBaseItem().SpriteId + "','" + ItemType + "','" + UberEnvironment.GetUnixTimestamp() + "',@extra_data)"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId); ServerPacket p610 = new ServerPacket(610); p610.AppendBoolean(true); Session.SendPacket(p610); }
public void parse(GameClient Session, ClientPacket Packet) { ServerPacket packet = new ServerPacket(512); packet.AppendBoolean(false); // true = show error with number below packet.AppendInt32(99999); Session.SendPacket(packet); // todo: room limit }
public void parse(GameClient Session, ClientPacket Packet) { uint RoomId = Packet.PopWiredUInt(); bool LoadingState = Packet.PopWiredBoolean(); bool Following = Packet.PopWiredBoolean(); RoomData Data = UberEnvironment.GetGame().GetRoomManager().GenerateRoomData(RoomId); if (Data == null) { return; } ServerPacket packet = new ServerPacket(454); packet.AppendBoolean(LoadingState); Data.Serialize(packet, false); packet.AppendBoolean(Following); packet.AppendBoolean(LoadingState); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } ServerPacket packet = new ServerPacket(465); packet.AppendUInt(Room.RoomId); packet.AppendStringWithBreak(Room.Name); packet.AppendStringWithBreak(Room.Description); packet.AppendInt32(Room.State); packet.AppendInt32(Room.Category); packet.AppendInt32(Room.UsersMax); packet.AppendInt32(25); packet.AppendInt32(Room.TagCount); foreach (string Tag in Room.Tags) { packet.AppendStringWithBreak(Tag); } packet.AppendInt32(Room.UsersWithRights.Count); // users /w rights count foreach (uint UserId in Room.UsersWithRights) { packet.AppendUInt(UserId); packet.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId)); } packet.AppendInt32(Room.UsersWithRights.Count); // users /w rights count packet.AppendBoolean(Room.AllowPets); // allows pets in room - pet system lacking, so always off packet.AppendBoolean(Room.AllowPetsEating); // allows pets to eat your food - pet system lacking, so always off packet.AppendBoolean(Room.AllowWalkthrough); packet.AppendBoolean(Room.Hidewall); Session.SendPacket(packet); }
public void Serialize(ServerPacket Message, Boolean Inventory) { Message.AppendUInt(Id); Message.AppendInt32(0); Message.AppendStringWithBreak(GetBaseItem().Type.ToUpper()); Message.AppendUInt(Id); Message.AppendInt32(GetBaseItem().SpriteId); if (GetBaseItem().Name.Contains("a2")) { Message.AppendInt32(3); } else if (GetBaseItem().Name.Contains("wallpaper")) { Message.AppendInt32(2); } else if (GetBaseItem().Name.Contains("landscape")) { Message.AppendInt32(4); } else { Message.AppendInt32(0); } Message.AppendStringWithBreak(ExtraData); Message.AppendBoolean(GetBaseItem().AllowRecycle); Message.AppendBoolean(GetBaseItem().AllowTrade); Message.AppendBoolean(GetBaseItem().AllowInventoryStack); Message.AppendBoolean(UberEnvironment.GetGame().GetCatalog().GetMarketplace().CanSellItem(this)); Message.AppendInt32(-1); if (GetBaseItem().Type.ToLower() == "s") { Message.AppendStringWithBreak(""); Message.AppendInt32(-1); } }
public void parse(GameClient Session, ClientPacket Packet) { uint Id = Packet.PopWiredUInt(); Session.GetHabbo().FavoriteRooms.Remove(Id); ServerPacket packet = new ServerPacket(459); packet.AppendUInt(Id); packet.AppendBoolean(false); Session.SendPacket(packet); using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.ExecuteQuery("DELETE FROM user_favorites WHERE user_id = '" + Session.GetHabbo().Id + "' AND room_id = '" + Id + "' LIMIT 1"); } }
public void parse(GameClient Session, ClientPacket Packet) { uint Id = Packet.PopWiredUInt(); CatalogItem Item = UberEnvironment.GetGame().GetCatalog().FindItem(Id); if (Item == null) { return; } ServerPacket packet = new ServerPacket(622); packet.AppendUInt(Item.Id); packet.AppendBoolean(Item.GetBaseItem().AllowGift); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } int itemCount = Packet.PopWiredInt32(); if (itemCount != 5) { return; } for (int i = 0; i < itemCount; i++) { UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(Packet.PopWiredUInt()); if (Item != null && Item.GetBaseItem().AllowRecycle) { Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id); } else { return; } } uint newItemId = UberEnvironment.GetGame().GetCatalog().GenerateItemId(); EcotronReward Reward = UberEnvironment.GetGame().GetCatalog().GetRandomEcotronReward(); using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.ExecuteQuery("INSERT INTO user_items (id,user_id,base_item,extra_data) VALUES ('" + newItemId + "','" + Session.GetHabbo().Id + "','1478','" + DateTime.Now.ToLongDateString() + "')"); dbClient.ExecuteQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES ('" + newItemId + "','" + Reward.BaseId + "','1','')"); } Session.GetHabbo().GetInventoryComponent().UpdateItems(true); ServerPacket packet = new ServerPacket(508); packet.AppendBoolean(true); packet.AppendUInt(newItemId); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { string SubscriptionId = Packet.PopFixedString(); ServerPacket packet = new ServerPacket(7); packet.AppendStringWithBreak(SubscriptionId.ToLower()); if (Session.GetHabbo().GetSubscriptionManager().HasSubscription(SubscriptionId)) { Double Expire = Session.GetHabbo().GetSubscriptionManager().GetSubscription(SubscriptionId).ExpireTime; Double TimeLeft = Expire - UberEnvironment.GetUnixTimestamp(); int TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400); int MonthsLeft = TotalDaysLeft / 31; if (MonthsLeft >= 1) MonthsLeft--; packet.AppendInt32(TotalDaysLeft - (MonthsLeft * 31)); packet.AppendBoolean(true); packet.AppendInt32(MonthsLeft); packet.AppendInt32(1); packet.AppendInt32(1); if (Session.GetHabbo().HasFuse("fuse_use_vip_outfits")) { packet.AppendInt32(2); } else { packet.AppendInt32(1); } } else { for (int i = 0; i < 3; i++) { packet.AppendInt32(0); } } Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null) { return; } RoomUser User = Room.GetRoomUserByHabbo(Session.GetHabbo().Id); if (User == null) { return; } ServerPacket Message = new ServerPacket(361); Message.AppendInt32(User.VirtualId); Message.AppendBoolean(true); Room.SendMessage(Message); }
public void parse(GameClient Session, ClientPacket Packet) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } Boolean Allow = true; int ErrorCode = 0; if (Room.State != 0) { Allow = false; ErrorCode = 3; } ServerPacket packet = new ServerPacket(367); packet.AppendBoolean(Allow); packet.AppendInt32(ErrorCode); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { uint BuddyId = Packet.PopWiredUInt(); GameClient Client = UberEnvironment.GetGame().GetClientManager().GetClientByHabbo(BuddyId); if (Client == null || Client.GetHabbo() == null || !Client.GetHabbo().InRoom) { return; } Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Client.GetHabbo().CurrentRoomId); if (Room == null) { return; } // D^HjTX]X ServerPacket packet = new ServerPacket(286); packet.AppendBoolean(Room.IsPublic); packet.AppendUInt(Client.GetHabbo().CurrentRoomId); Session.SendPacket(packet); }
public void parse(GameClient Session, ClientPacket Packet) { Boolean errorOccured = false; if (UberEnvironment.GetGame().GetModerationTool().UsersHasPendingTicket(Session.GetHabbo().Id)) { errorOccured = true; } if (!errorOccured) { string Message = UberEnvironment.FilterInjectionChars(Packet.PopFixedString()); int Junk = Packet.PopWiredInt32(); int Type = Packet.PopWiredInt32(); uint ReportedUser = Packet.PopWiredUInt(); UberEnvironment.GetGame().GetModerationTool().SendNewTicket(Session, Type, ReportedUser, Message); } ServerPacket packet = new ServerPacket(321); packet.AppendBoolean(errorOccured); Session.SendPacket(packet); }
public ServerPacket SerializeFlatCategories() { ServerPacket Cats = new ServerPacket(221); Cats.AppendInt32(PrivateCategories.Count); foreach (FlatCat FlatCat in PrivateCategories) { if (FlatCat.Id > 0) { Cats.AppendBoolean(true); } Cats.AppendInt32(FlatCat.Id); Cats.AppendStringWithBreak(FlatCat.Caption); } Cats.AppendStringWithBreak(""); return Cats; }
public ServerPacket SerializeUserInfo(uint UserId) { DataRow User = null; DataRow Info = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { User = dbClient.ReadDataRow("SELECT * FROM users WHERE id = '" + UserId + "' LIMIT 1"); Info = dbClient.ReadDataRow("SELECT * FROM user_info WHERE user_id = '" + UserId + "' LIMIT 1"); } if (User == null) { throw new ArgumentException(); } ServerPacket Message = new ServerPacket(533); Message.AppendUInt((uint)User["id"]); Message.AppendStringWithBreak((string)User["username"]); if (Info != null) { Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["reg_timestamp"]) / 60)); Message.AppendInt32((int)Math.Ceiling((UberEnvironment.GetUnixTimestamp() - (Double)Info["login_timestamp"]) / 60)); } else { Message.AppendInt32(0); Message.AppendInt32(0); } if (User["online"].ToString() == "1") { Message.AppendBoolean(true); } else { Message.AppendBoolean(false); } if (Info != null) { Message.AppendInt32((int)Info["cfhs"]); Message.AppendInt32((int)Info["cfhs_abusive"]); Message.AppendInt32((int)Info["cautions"]); Message.AppendInt32((int)Info["bans"]); } else { Message.AppendInt32(0); // cfhs Message.AppendInt32(0); // abusive cfhs Message.AppendInt32(0); // cautions Message.AppendInt32(0); // bans } return Message; }
public ServerPacket SerializeUserChatlog(uint UserId) { DataTable Visits = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Visits = dbClient.ReadDataTable("SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE user_id = '" + UserId + "' ORDER BY entry_timestamp DESC LIMIT 5"); } ServerPacket Message = new ServerPacket(536); Message.AppendUInt(UserId); Message.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId)); if (Visits != null) { Message.AppendInt32(Visits.Rows.Count); foreach (DataRow Visit in Visits.Rows) { DataTable Chatlogs = null; if ((Double)Visit["exit_timestamp"] <= 0.0) { Visit["exit_timestamp"] = UberEnvironment.GetUnixTimestamp(); } using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Chatlogs = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + (uint)Visit["room_id"] + "' AND timestamp > '" + (Double)Visit["entry_timestamp"] + "' AND timestamp < '" + (Double)Visit["exit_timestamp"] + "' ORDER BY timestamp DESC"); } RoomData RoomData = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)Visit["room_id"]); Message.AppendBoolean(RoomData.IsPublicRoom); Message.AppendUInt(RoomData.Id); Message.AppendStringWithBreak(RoomData.Name); if (Chatlogs != null) { Message.AppendInt32(Chatlogs.Rows.Count); foreach (DataRow Log in Chatlogs.Rows) { Message.AppendInt32((int)Log["hour"]); Message.AppendInt32((int)Log["minute"]); Message.AppendUInt((uint)Log["user_id"]); Message.AppendStringWithBreak((string)Log["user_name"]); Message.AppendStringWithBreak((string)Log["message"]); } } else { Message.AppendInt32(0); } } } else { Message.AppendInt32(0); } return Message; }
public ServerPacket SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, Double Timestamp) { DataTable Data = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Data = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + RoomData.Id + "' AND timestamp >= '" + (Timestamp - 300) + "' AND timestamp <= '" + Timestamp + "' ORDER BY timestamp DESC"); } ServerPacket Message = new ServerPacket(534); Message.AppendUInt(Ticket.TicketId); Message.AppendUInt(Ticket.SenderId); Message.AppendUInt(Ticket.ReportedId); Message.AppendBoolean(RoomData.IsPublicRoom); Message.AppendUInt(RoomData.Id); Message.AppendStringWithBreak(RoomData.Name); if (Data != null) { Message.AppendInt32(Data.Rows.Count); foreach (DataRow Row in Data.Rows) { Message.AppendInt32((int)Row["hour"]); Message.AppendInt32((int)Row["minute"]); Message.AppendUInt((uint)Row["user_id"]); Message.AppendStringWithBreak((string)Row["user_name"]); Message.AppendStringWithBreak((string)Row["message"]); } } else { Message.AppendInt32(0); } return Message; }
public ServerPacket SerializeRoomVisits(uint UserId) { DataTable Data = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Data = dbClient.ReadDataTable("SELECT room_id,hour,minute FROM user_roomvisits WHERE user_id = '" + UserId + "' ORDER BY entry_timestamp DESC LIMIT 50"); } ServerPacket Message = new ServerPacket(537); Message.AppendUInt(UserId); Message.AppendStringWithBreak(UberEnvironment.GetGame().GetClientManager().GetNameById(UserId)); if (Data != null) { Message.AppendInt32(Data.Rows.Count); foreach (DataRow Row in Data.Rows) { RoomData RoomData = UberEnvironment.GetGame().GetRoomManager().GenerateNullableRoomData((uint)Row["room_id"]); Message.AppendBoolean(RoomData.IsPublicRoom); Message.AppendUInt(RoomData.Id); Message.AppendStringWithBreak(RoomData.Name); Message.AppendInt32((int)Row["hour"]); Message.AppendInt32((int)Row["minute"]); } } else { Message.AppendInt32(0); } return Message; }
public ServerPacket SerializeRoomTool(RoomData Data) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Data.Id); uint OwnerId = 0; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { try { OwnerId = (uint)dbClient.ReadDataRow("SELECT id FROM users WHERE username = '******' LIMIT 1")[0]; } catch (Exception) { } } ServerPacket Message = new ServerPacket(538); Message.AppendUInt(Data.Id); Message.AppendInt32(Data.UsersNow); // user count if (Room != null) { Message.AppendBoolean((Room.GetRoomUserByHabbo(Data.Owner) != null)); } else { Message.AppendBoolean(false); } Message.AppendUInt(OwnerId); Message.AppendStringWithBreak(Data.Owner); Message.AppendUInt(Data.Id); Message.AppendStringWithBreak(Data.Name); Message.AppendStringWithBreak(Data.Description); Message.AppendInt32(Data.TagCount); foreach (string Tag in Data.Tags) { Message.AppendStringWithBreak(Tag); } if (Room != null) { Message.AppendBoolean(Room.HasOngoingEvent); if (Room.Event != null) { Message.AppendStringWithBreak(Room.Event.Name); Message.AppendStringWithBreak(Room.Event.Description); Message.AppendInt32(Room.Event.Tags.Count); foreach (string Tag in Room.Event.Tags) { Message.AppendStringWithBreak(Tag); } } } else { Message.AppendBoolean(false); } return Message; }
public ServerPacket Serialize() { ServerPacket Message = new ServerPacket(460); Message.AppendInt32(Count); foreach (AvatarEffect Effect in Effects) { Message.AppendInt32(Effect.EffectId); Message.AppendInt32(Effect.TotalDuration); Message.AppendBoolean(!Effect.Activated); Message.AppendInt32(Effect.TimeLeft); } return Message; }
public ServerPacket SerializeSearchResults(string Query) { DataTable Results = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.AddParamWithValue("query", Query); Results = dbClient.ReadDataTable("SELECT id,title FROM help_topics WHERE title LIKE @query OR body LIKE @query LIMIT 25"); } ServerPacket Search = new ServerPacket(521); if (Results == null) { Search.AppendBoolean(false); return Search; } Search.AppendInt32(Results.Rows.Count); foreach (DataRow Row in Results.Rows) { Search.AppendUInt((uint)Row["id"]); Search.AppendStringWithBreak((string)Row["title"]); } return Search; }
public void parse(GameClient Session, ClientPacket Packet) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } int Junk = Packet.PopWiredInt32(); // always 3 Dictionary<int, int> Items = new Dictionary<int, int>(); int Background = Packet.PopWiredInt32(); int TopLayer = Packet.PopWiredInt32(); int AmountOfItems = Packet.PopWiredInt32(); for (int i = 0; i < AmountOfItems; i++) { int Pos = Packet.PopWiredInt32(); int Item = Packet.PopWiredInt32(); if (Pos < 0 || Pos > 10) { return; } if (Item < 1 || Item > 27) { return; } if (Items.ContainsKey(Pos)) { return; } Items.Add(Pos, Item); } if (Background < 1 || Background > 24) { return; } if (TopLayer < 0 || TopLayer > 11) { return; } StringBuilder FormattedItems = new StringBuilder(); int j = 0; foreach (KeyValuePair<int, int> Item in Items) { if (j > 0) { FormattedItems.Append("|"); } FormattedItems.Append(Item.Key + "," + Item.Value); j++; } using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { dbClient.ExecuteQuery("UPDATE rooms SET icon_bg = '" + Background + "', icon_fg = '" + TopLayer + "', icon_items = '" + FormattedItems.ToString() + "' WHERE id = '" + Room.RoomId + "' LIMIT 1"); } Room.Icon = new RoomIcon(Background, TopLayer, Items); ServerPacket packet = new ServerPacket(457); packet.AppendUInt(Room.RoomId); packet.AppendBoolean(true); Session.SendPacket(packet); packet = new ServerPacket(456); packet.AppendUInt(Room.RoomId); Session.SendPacket(packet); RoomData Data = new RoomData(); Data.Fill(Room); ServerPacket _packet = new ServerPacket(454); _packet.AppendBoolean(false); Data.Serialize(_packet, false); _packet.AppendBoolean(false); _packet.AppendBoolean(false); Session.SendPacket(_packet); }
public ServerPacket SerializeUpdates() { List<MessengerBuddy> UpdateBuddies = new List<MessengerBuddy>(); int UpdateCount = 0; foreach (MessengerBuddy Buddy in Buddies) { if (Buddy.UpdateNeeded) { UpdateCount++; UpdateBuddies.Add(Buddy); Buddy.UpdateNeeded = false; } } ServerPacket Updates = new ServerPacket(13); Updates.AppendInt32(0); Updates.AppendInt32(UpdateCount); Updates.AppendInt32(0); foreach (MessengerBuddy Buddy in UpdateBuddies) { Buddy.Serialize(Updates, false); Updates.AppendBoolean(false); } return Updates; }
public ServerPacket SerializeRoomChatlog(uint RoomId) { Room Room = UberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId); if (Room == null) { throw new ArgumentException(); } Boolean IsPublic = false; if (Room.Type.ToLower() == "public") { IsPublic = true; } DataTable Data = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Data = dbClient.ReadDataTable("SELECT user_id,user_name,hour,minute,message FROM chatlogs WHERE room_id = '" + Room.RoomId + "' ORDER BY timestamp DESC LIMIT 150"); } ServerPacket Message = new ServerPacket(535); Message.AppendBoolean(IsPublic); Message.AppendUInt(Room.RoomId); Message.AppendStringWithBreak(Room.Name); if (Data != null) { Message.AppendInt32(Data.Rows.Count); foreach (DataRow Row in Data.Rows) { Message.AppendInt32((int)Row["hour"]); Message.AppendInt32((int)Row["minute"]); Message.AppendUInt((uint)Row["user_id"]); Message.AppendStringWithBreak((string)Row["user_name"]); Message.AppendStringWithBreak((string)Row["message"]); } } else { Message.AppendInt32(0); } return Message; }