public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { //0 = sent, 1 = blocked, 2 = no chat, 3 = already reported. if (Session == null) return; int UserId = Packet.PopInt(); if (UserId == Session.GetHabbo().Id)//Hax return; if (Session.GetHabbo().AdvertisingReportedBlocked) { Session.SendMessage(new SubmitBullyReportComposer(1));//This user is blocked from reporting. return; } GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Convert.ToInt32(UserId)); if (Client == null) { Session.SendMessage(new SubmitBullyReportComposer(0));//Just say it's sent, the user isn't found. return; } if (Session.GetHabbo().LastAdvertiseReport > PlusEnvironment.GetUnixTimestamp()) { Session.SendNotification("Reports can only be sent per 5 minutes!"); return; } if (Client.GetHabbo().GetPermissions().HasRight("mod_tool"))//Reporting staff, nope! { Session.SendNotification("Sorry, you cannot report staff members via this tool."); return; } //This user hasn't even said a word, nope! if (!Client.GetHabbo().HasSpoken) { Session.SendMessage(new SubmitBullyReportComposer(2)); return; } //Already reported, nope. if (Client.GetHabbo().AdvertisingReported && Session.GetHabbo().Rank < 2) { Session.SendMessage(new SubmitBullyReportComposer(3)); return; } if (Session.GetHabbo().Rank <= 1) Session.GetHabbo().LastAdvertiseReport = PlusEnvironment.GetUnixTimestamp() + 300; else Session.GetHabbo().LastAdvertiseReport = PlusEnvironment.GetUnixTimestamp(); Client.GetHabbo().AdvertisingReported = true; Session.SendMessage(new SubmitBullyReportComposer(0)); //PlusEnvironment.GetGame().GetClientManager().ModAlert("New advertising report! " + Client.GetHabbo().Username + " has been reported for advertising by " + Session.GetHabbo().Username +"."); PlusEnvironment.GetGame().GetClientManager().DoAdvertisingReport(Session, Client); return; }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; int ItemId = Packet.PopInt(); Item Item = Room.GetRoomItemHandler().GetItem(ItemId); if (Item == null) return; if (Item.Data == null) return; if (Item.UserID != Session.GetHabbo().Id) return; if (Item.Data.InteractionType != InteractionType.PURCHASABLE_CLOTHING) { Session.SendNotification("Oops, this item isn't set as a sellable clothing item!"); return; } if (Item.Data.ClothingId == 0) { Session.SendNotification("Oops, this item doesn't have a linking clothing configuration, please report it!"); return; } ClothingItem Clothing = null; if (!PlusEnvironment.GetGame().GetCatalog().GetClothingManager().TryGetClothing(Item.Data.ClothingId, out Clothing)) { Session.SendNotification("Oops, we couldn't find this clothing part!"); return; } //Quickly delete it from the database. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", Item.Id); dbClient.RunQuery(); } //Remove the item. Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id); Session.GetHabbo().GetClothing().AddClothing(Clothing.ClothingName, Clothing.PartIds); Session.SendMessage(new FigureSetIdsComposer(Session.GetHabbo().GetClothing().GetClothingAllParts)); Session.SendMessage(new RoomNotificationComposer("figureset.redeemed.success")); Session.SendWhisper("If for some reason cannot see your new clothing, reload the hotel!"); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { Group Group = null; if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(Packet.PopInt(), out Group)) { Session.SendNotification("Oops, we couldn't find that group!"); return; } if (Group.CreatorId != Session.GetHabbo().Id && !Session.GetHabbo().GetPermissions().HasRight("group_delete_override"))//Maybe a FUSE check for staff override? { Session.SendNotification("Oops, only the group owner can delete a group!"); return; } if (Group.MemberCount >= PlusStaticGameSettings.GroupMemberDeletionLimit && !Session.GetHabbo().GetPermissions().HasRight("group_delete_limit_override")) { Session.SendNotification("Oops, your group exceeds the maximum amount of members (" + PlusStaticGameSettings.GroupMemberDeletionLimit + ") a group can exceed before being eligible for deletion. Seek assistance from a staff member."); return; } Room Room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Group.RoomId); if (Room != null) { Room.Group = null; Room.RoomData.Group = null;//I'm not sure if this is needed or not, becauseof inheritance, but oh well. } //Remove it from the cache. PlusEnvironment.GetGame().GetGroupManager().DeleteGroup(Group.Id); //Now the :S stuff. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `groups` WHERE `id` = '" + Group.Id + "'"); dbClient.RunQuery("DELETE FROM `group_memberships` WHERE `group_id` = '" + Group.Id + "'"); dbClient.RunQuery("DELETE FROM `group_requests` WHERE `group_id` = '" + Group.Id + "'"); dbClient.RunQuery("UPDATE `rooms` SET `group_id` = '0' WHERE `group_id` = '" + Group.Id + "' LIMIT 1"); dbClient.RunQuery("UPDATE `user_stats` SET `groupid` = '0' WHERE `groupid` = '" + Group.Id + "' LIMIT 1"); dbClient.RunQuery("DELETE FROM `items_groups` WHERE `group_id` = '" + Group.Id + "'"); } //Unload it last. PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(Room, true); //Say hey! Session.SendNotification("You have successfully deleted your group."); return; }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int GroupId = Packet.PopInt(); int UserId = Packet.PopInt(); Group Group = null; if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(GroupId, out Group)) return; if ((Session.GetHabbo().Id != Group.CreatorId && !Group.IsAdmin(Session.GetHabbo().Id)) && !Session.GetHabbo().GetPermissions().HasRight("fuse_group_accept_any")) return; if (!Group.HasRequest(UserId)) return; Habbo Habbo = PlusEnvironment.GetHabboById(UserId); if (Habbo == null) { Session.SendNotification("Oops, an error occurred whilst finding this user."); return; } Group.HandleRequest(UserId, true); Session.SendMessage(new GroupMemberUpdatedComposer(GroupId, Habbo, 4)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int RoomId = Packet.PopInt(); string Name = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString()); string Desc = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString()); RoomData Data = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(RoomId); if (Data == null) return; if (Data.OwnerId != Session.GetHabbo().Id) return;//HAX if (Data.Promotion == null) { Session.SendNotification("Oops, it looks like there isn't a room promotion in this room?"); return; } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `room_promotions` SET `title` = @title, `description` = @desc WHERE `room_id` = " + RoomId + " LIMIT 1"); dbClient.AddParameter("title", Name); dbClient.AddParameter("desc", Desc); dbClient.RunQuery(); } Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Convert.ToInt32(RoomId), out Room)) return; Data.Promotion.Name = Name; Data.Promotion.Description = Desc; Room.SendMessage(new RoomEventComposer(Data, Data.Promotion)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool")) return; int UserId = Packet.PopInt(); DataRow User = null; DataRow Info = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `id`,`username`,`online`,`mail`,`ip_last`,`look`,`account_created`,`last_online` FROM `users` WHERE `id` = '" + UserId + "' LIMIT 1"); User = dbClient.getRow(); if (User == null) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("user_not_found")); return; } dbClient.SetQuery("SELECT `cfhs`,`cfhs_abusive`,`cautions`,`bans`,`trading_locked`,`trading_locks_count` FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); Info = dbClient.getRow(); if (Info == null) { dbClient.RunQuery("INSERT INTO `user_info` (`user_id`) VALUES ('" + UserId + "')"); dbClient.SetQuery("SELECT `cfhs`,`cfhs_abusive`,`cautions`,`bans`,`trading_locked`,`trading_locks_count` FROM `user_info` WHERE `user_id` = '" + UserId + "' LIMIT 1"); Info = dbClient.getRow(); } } Session.SendMessage(new ModeratorUserInfoComposer(User, Info)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null) return; if (!Session.GetHabbo().InRoom) return; int ItemId = Packet.PopInt(); Session.SendMessage(new HideWiredConfigComposer()); Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; Item SelectedItem = Room.GetRoomItemHandler().GetItem(ItemId); if (SelectedItem == null) return; IWiredItem Box = null; if (!Session.GetHabbo().CurrentRoom.GetWired().TryGet(ItemId, out Box)) return; if (Box.Type == WiredBoxType.EffectGiveUserBadge && !Session.GetHabbo().GetPermissions().HasRight("room_item_wired_rewards")) { Session.SendNotification("You don't have the correct permissions to do this."); return; } Box.HandleSave(Packet); Session.GetHabbo().CurrentRoom.GetWired().SaveBox(Box); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null) return; if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool")) return; int UserId = Packet.PopInt(); Habbo Habbo = PlusEnvironment.GetHabboById(UserId); if (Habbo == null) { Session.SendNotification("Oops, we couldn't find this user."); return; } try { Session.SendMessage(new ModeratorUserChatlogComposer(UserId)); } catch { Session.SendNotification("Overflow :/"); } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { string CipherPublickey = Packet.PopString(); BigInteger SharedKey = HabboEncryptionV2.CalculateDiffieHellmanSharedKey(CipherPublickey); if (SharedKey != 0) { Session.RC4Client = new ARC4(SharedKey.getBytes()); Session.SendMessage(new SecretKeyComposer(HabboEncryptionV2.GetRsaDiffieHellmanPublicKey())); } else { Session.SendNotification("There was an error logging you in, please try again!"); return; } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; if (!Room.CheckRights(Session, true)) return; if (PlusEnvironment.GetDBConfig().DBData["exchange_enabled"] != "1") { Session.SendNotification("The hotel managers have temporarilly disabled exchanging!"); return; } Item Exchange = Room.GetRoomItemHandler().GetItem(Packet.PopInt()); if (Exchange == null) return; if (!Exchange.GetBaseItem().ItemName.StartsWith("CF_") && !Exchange.GetBaseItem().ItemName.StartsWith("CFC_")) return; string[] Split = Exchange.GetBaseItem().ItemName.Split('_'); int Value = int.Parse(Split[1]); if (Value > 0) { Session.GetHabbo().Credits += Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Exchange.Id + "' LIMIT 1"); } Session.SendMessage(new FurniListUpdateComposer()); Room.GetRoomItemHandler().RemoveFurniture(null, Exchange.Id, false); Session.GetHabbo().GetInventoryComponent().RemoveItem(Exchange.Id); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session.GetHabbo().TimeMuted > 0) { Session.SendNotification("Oops, you're currently muted - you cannot send room invitations."); return; } int Amount = Packet.PopInt(); if (Amount > 500) return; // don't send at all List<int> Targets = new List<int>(); for (int i = 0; i < Amount; i++) { int uid = Packet.PopInt(); if (i < 100) // limit to 100 people, keep looping until we fulfil the request though { Targets.Add(uid); } } string Message = StringCharFilter.Escape(Packet.PopString()); if (Message.Length > 121) Message = Message.Substring(0, 121); foreach (int UserId in Targets) { if (!Session.GetHabbo().GetMessenger().FriendshipExists(UserId)) continue; GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().AllowMessengerInvites == true || Client.GetHabbo().AllowConsoleMessages == false) continue; Client.SendMessage(new RoomInviteComposer(Session.GetHabbo().Id, Message)); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `chatlogs_console_invitations` (`user_id`,`message`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @message, UNIX_TIMESTAMP())"); dbClient.AddParameter("message", Message); dbClient.RunQuery(); } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int SellingPrice = Packet.PopInt(); int ComissionPrice = Packet.PopInt(); int ItemId = Packet.PopInt(); Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId); if (Item == null) { Session.SendMessage(new MarketplaceMakeOfferResultComposer(0)); return; } if (!ItemUtility.IsRare(Item)) { Session.SendNotification("Sorry, only Rares & LTDs can go be auctioned off in the Marketplace!"); return; } if (SellingPrice > 70000000 || SellingPrice == 0) { Session.SendMessage(new MarketplaceMakeOfferResultComposer(0)); return; } int Comission = PlusEnvironment.GetGame().GetCatalog().GetMarketplace().CalculateComissionPrice((float)SellingPrice); int TotalPrice = SellingPrice + Comission; int ItemType = 1; if (Item.GetBaseItem().Type == 'i') ItemType++; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `catalog_marketplace_offers` (`furni_id`,`item_id`,`user_id`,`asking_price`,total_price,public_name,sprite_id,item_type,timestamp,extra_data,limited_number,limited_stack) VALUES ('" + ItemId + "','" + Item.BaseItem + "','" + Session.GetHabbo().Id + "','" + SellingPrice + "','" + TotalPrice + "',@public_name,'" + Item.GetBaseItem().SpriteId + "','" + ItemType + "','" + PlusEnvironment.GetUnixTimestamp() + "',@extra_data, '" + Item.LimitedNo + "', '" + Item.LimitedTot + "')"); dbClient.AddParameter("public_name", Item.GetBaseItem().PublicName); dbClient.AddParameter("extra_data", Item.ExtraData); dbClient.RunQuery(); dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + ItemId + "' AND `user_id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId); Session.SendMessage(new MarketplaceMakeOfferResultComposer(1)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null) return; int UserId = Packet.PopInt(); Room Room = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; if (!Room.CheckRights(Session, true)) return; if (Room.UsersWithRights.Contains(UserId)) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("room_rights_has_rights_error")); return; } Room.UsersWithRights.Add(UserId); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("INSERT INTO `room_rights` (`room_id`,`user_id`) VALUES ('" + Room.RoomId + "','" + UserId + "')"); } RoomUser RoomUser = Room.GetRoomUserManager().GetRoomUserByHabbo(UserId); if (RoomUser != null && !RoomUser.IsBot) { RoomUser.SetStatus("flatctrl 1", ""); RoomUser.UpdateNeeded = true; if (RoomUser.GetClient() != null) RoomUser.GetClient().SendMessage(new YouAreControllerComposer(1)); Session.SendMessage(new FlatControllerAddedComposer(Room.RoomId, RoomUser.GetClient().GetHabbo().Id, RoomUser.GetClient().GetHabbo().Username)); } else { UserCache User = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(UserId); if (User != null) Session.SendMessage(new FlatControllerAddedComposer(Room.RoomId, User.Id, User.Username)); } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null) return; if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool")) return; int Junk = Packet.PopInt(); Room Room = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Packet.PopInt(), out Room)) return; try { Session.SendMessage(new ModeratorRoomChatlogComposer(Room)); } catch { Session.SendNotification("Overflow :/"); } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { ICollection<Item> FloorItems = Session.GetHabbo().GetInventoryComponent().GetFloorItems(); ICollection<Item> WallItems = Session.GetHabbo().GetInventoryComponent().GetWallItems(); if (Session.GetHabbo().InventoryAlert == false) { Session.GetHabbo().InventoryAlert = true; int TotalCount = FloorItems.Count + WallItems.Count; if (TotalCount >= 5000) { Session.SendNotification("Hey! Our system has detected that you have a very large inventory!\n\n" + "The maximum an inventory can load is 8000 items, you have " + TotalCount + " items loaded now.\n\n" + "If you have 8000 loaded now then you're probably over the limit and some items will be hidden until you free up space.\n\n" + "Please note that we are not responsible for you crashing because of too large inventorys!"); } } Session.SendMessage(new FurniListComposer(FloorItems.ToList(), WallItems)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetMessenger() == null) return; int userId = Packet.PopInt(); if (userId == 0 || userId == Session.GetHabbo().Id) return; string message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString()); if (string.IsNullOrWhiteSpace(message)) return; if (Session.GetHabbo().TimeMuted > 0) { Session.SendNotification("Oops, you're currently muted - you cannot send messages."); return; } Session.GetHabbo().GetMessenger().SendInstantMessage(userId, message); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int GroupId = Packet.PopInt(); int UserId = Packet.PopInt(); Group Group = null; if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(GroupId, out Group)) return; if (Session.GetHabbo().Id != Group.CreatorId || !Group.IsMember(UserId)) return; Habbo Habbo = PlusEnvironment.GetHabboById(UserId); if (Habbo == null) { Session.SendNotification("Oops, an error occurred whilst finding this user."); return; } Group.TakeAdmin(UserId); Room Room = null; if (PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Group.RoomId, out Room)) { RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(UserId); if (User != null) { if (User.Statusses.ContainsKey("flatctrl 3")) User.RemoveStatus("flatctrl 3"); User.UpdateNeeded = true; if (User.GetClient() != null) User.GetClient().SendMessage(new YouAreControllerComposer(0)); } } Session.SendMessage(new GroupMemberUpdatedComposer(GroupId, Habbo, 2)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int userID = Packet.PopInt(); Boolean IsMe = Packet.PopBoolean(); Habbo targetData = PlusEnvironment.GetHabboById(userID); if (targetData == null) { Session.SendNotification("An error occured whilst finding that user's profile."); return; } List<Group> Groups = PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(targetData.Id); int friendCount = 0; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT COUNT(0) FROM `messenger_friendships` WHERE (`user_one_id` = @userid OR `user_two_id` = @userid)"); dbClient.AddParameter("userid", userID); friendCount = dbClient.getInteger(); } Session.SendMessage(new ProfileInformationComposer(targetData, Session, Groups, friendCount)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().GetPermissions().HasRight("mod_kick")) return; int UserId = Packet.PopInt(); string Message = Packet.PopString(); GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId); if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().CurrentRoomId < 1 || Client.GetHabbo().Id == Session.GetHabbo().Id) return; if (Client.GetHabbo().Rank >= Session.GetHabbo().Rank) { Session.SendNotification(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("moderation_kick_permissions")); return; } Room Room = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; Room.GetRoomUserManager().RemoveUserFromRoom(Client, true, false); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; int ItemId = Packet.PopInt(); Item Item = Room.GetRoomItemHandler().GetItem(ItemId); if (Item == null || Item.Data == null) return; string PetName = Packet.PopString(); if (string.IsNullOrEmpty(PetName)) { Session.SendMessage(new CheckGnomeNameComposer(PetName, 1)); return; } int X = Item.GetX; int Y = Item.GetY; //Quickly delete it from the database. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", Item.Id); dbClient.RunQuery(); } //Remove the item. Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id); //Apparently we need this for success. Session.SendMessage(new CheckGnomeNameComposer(PetName, 0)); //Create the pet here. Pet Pet = PetUtility.CreatePet(Session.GetHabbo().Id, PetName, 26, "30", "ffffff"); if (Pet == null) { Session.SendNotification("Oops, an error occoured. Please report this!"); return; } List<RandomSpeech> RndSpeechList = new List<RandomSpeech>(); List<BotResponse> BotResponse = new List<BotResponse>(); Pet.RoomId = Session.GetHabbo().CurrentRoomId; Pet.GnomeClothing = RandomClothing(); //Update the pets gnome clothing. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1"); dbClient.AddParameter("GnomeClothing", Pet.GnomeClothing); dbClient.AddParameter("PetId", Pet.PetId); dbClient.RunQuery(); } //Make a RoomUser of the pet. RoomUser PetUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Pet.PetId, Pet.RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, X, Y, 0, 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0), Pet); //Give the food. ItemData PetFood = null; if (PlusEnvironment.GetGame().GetItemManager().GetItem(320, out PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), "", ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendMessage(new FurniListNotificationComposer(Food.Id, 1)); } } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string Data = Packet.PopString(); string GiftUser = StringCharFilter.Escape(Packet.PopString()); string GiftMessage = StringCharFilter.Escape(Packet.PopString().Replace(Convert.ToChar(5), ' ')); int SpriteId = Packet.PopInt(); int Ribbon = Packet.PopInt(); int Colour = Packet.PopInt(); bool dnow = Packet.PopBoolean(); if (PlusEnvironment.GetDBConfig().DBData["gifts_enabled"] != "1") { Session.SendNotification("The hotel managers have disabled gifting"); return; } /*if (PlusEnvironment.GetGame().GetCatalog().CatalogFlatOffers.ContainsKey(ItemId) && PageId < 0) { PageId = PlusEnvironment.GetGame().GetCatalog().CatalogFlatOffers[ItemId]; CatalogPage P = null; if (!PlusEnvironment.GetGame().GetCatalog().Pages.TryGetValue(PageId, out P)) PageId = 0; }*/ CatalogPage Page = null; if (!PlusEnvironment.GetGame().GetCatalog().TryGetPage(PageId, out Page)) return; if ( !Page.Enabled || !Page.Visible || Page.MinimumRank > Session.GetHabbo().Rank || (Page.MinimumVIP > Session.GetHabbo().VIPRank && Session.GetHabbo().Rank == 1)) return; CatalogItem Item = null; if (!Page.Items.TryGetValue(ItemId, out Item)) { if (Page.ItemOffers.ContainsKey(ItemId)) { Item = (CatalogItem)Page.ItemOffers[ItemId]; if (Item == null) return; } else return; } if (!ItemUtility.CanGiftItem(Item)) return; ItemData PresentData = null; if (!PlusEnvironment.GetGame().GetItemManager().GetGift(SpriteId, out PresentData) || PresentData.InteractionType != InteractionType.GIFT) return; if (Session.GetHabbo().Credits < Item.CostCredits) { Session.SendMessage(new PresentDeliverErrorMessageComposer(true, false)); return; } if (Session.GetHabbo().Duckets < Item.CostPixels) { Session.SendMessage(new PresentDeliverErrorMessageComposer(false, true)); return; } Habbo Habbo = PlusEnvironment.GetHabboByUsername(GiftUser); if (Habbo == null) { Session.SendMessage(new GiftWrappingErrorComposer()); return; } if (!Habbo.AllowGifts) { Session.SendNotification("Oops, this user doesn't allow gifts to be sent to them!"); return; } if ((DateTime.Now - Session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0) { Session.SendNotification("You're purchasing gifts too fast! Please wait 15 seconds!"); Session.GetHabbo().GiftPurchasingWarnings += 1; if (Session.GetHabbo().GiftPurchasingWarnings >= 25) Session.GetHabbo().SessionGiftBlocked = true; return; } if (Session.GetHabbo().SessionGiftBlocked) return; string ED = GiftUser + Convert.ToChar(5) + GiftMessage + Convert.ToChar(5) + Session.GetHabbo().Id + Convert.ToChar(5) + Item.Data.Id + Convert.ToChar(5) + SpriteId + Convert.ToChar(5) + Ribbon + Convert.ToChar(5) + Colour; int NewItemId = 0; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { //Insert the dummy item. dbClient.SetQuery("INSERT INTO `items` (`base_item`,`user_id`,`extra_data`) VALUES ('" + PresentData.Id + "', '" + Habbo.Id + "', @extra_data)"); dbClient.AddParameter("extra_data", ED); NewItemId = Convert.ToInt32(dbClient.InsertQuery()); string ItemExtraData = null; switch (Item.Data.InteractionType) { case InteractionType.NONE: ItemExtraData = ""; break; #region Pet handling case InteractionType.pet0: case InteractionType.pet1: case InteractionType.pet2: case InteractionType.pet3: case InteractionType.pet4: case InteractionType.pet5: case InteractionType.pet6: case InteractionType.pet7: case InteractionType.pet8: case InteractionType.pet9: case InteractionType.pet10: case InteractionType.pet11: case InteractionType.pet12: case InteractionType.pet13: //Caballo case InteractionType.pet14: case InteractionType.pet15: case InteractionType.pet16: //Mascota agregada case InteractionType.pet17: //Mascota agregada case InteractionType.pet18: //Mascota agregada case InteractionType.pet19: //Mascota agregada case InteractionType.pet20: //Mascota agregada case InteractionType.pet21: //Mascota agregada case InteractionType.pet22: //Mascota agregada case InteractionType.pet28: case InteractionType.pet29: case InteractionType.pet30: try { string[] Bits = Data.Split('\n'); string PetName = Bits[0]; string Race = Bits[1]; string Color = Bits[2]; int.Parse(Race); // to trigger any possible errors if (PetUtility.CheckPetName(PetName)) return; if (Race.Length > 2) return; if (Color.Length != 6) return; PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); } catch { return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(Data)) Number = 0; else Number = Double.Parse(Data, PlusEnvironment.CultureInfo); } catch { } ItemExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ItemExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ItemExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ItemExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + Data; break; case InteractionType.MANNEQUIN: ItemExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin"; break; case InteractionType.BADGE_DISPLAY: if (!Session.GetHabbo().GetBadgeComponent().HasBadge(Data)) { Session.SendMessage(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge.")); return; } ItemExtraData = Data + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; default: ItemExtraData = Data; break; } //Insert the present, forever. dbClient.SetQuery("INSERT INTO `user_presents` (`item_id`,`base_id`,`extra_data`) VALUES ('" + NewItemId + "', '" + Item.Data.Id + "', @extra_data)"); dbClient.AddParameter("extra_data", (string.IsNullOrEmpty(ItemExtraData) ? "" : ItemExtraData)); dbClient.RunQuery(); //Here we're clearing up a record, this is dumb, but okay. dbClient.RunQuery("DELETE FROM `items` WHERE `id` = " + NewItemId + " LIMIT 1;"); } Item GiveItem = ItemFactory.CreateGiftItem(PresentData, Habbo, ED, ED, NewItemId, 0, 0); if (GiveItem != null) { GameClient Receiver = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Habbo.Id); if (Receiver != null) { Receiver.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem); Receiver.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1)); Receiver.SendMessage(new PurchaseOKComposer()); Receiver.SendMessage(new FurniListAddComposer(GiveItem)); Receiver.SendMessage(new FurniListUpdateComposer()); } if (Habbo.Id != Session.GetHabbo().Id && !string.IsNullOrWhiteSpace(GiftMessage)) { PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_GiftGiver", 1); if (Receiver != null) PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Receiver, "ACH_GiftReceiver", 1); PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.GIFT_OTHERS); } } Session.SendMessage(new PurchaseOKComposer(Item, PresentData)); if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= Item.CostCredits; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostPixels > 0) { Session.GetHabbo().Duckets -= Item.CostPixels; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets)); } Session.GetHabbo().LastGiftPurchaseTime = DateTime.Now; }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id); if (User == null) return; int PetId = Packet.PopInt(); bool Type = Packet.PopBoolean(); RoomUser Pet = null; if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet)) return; if (Pet.PetData == null) return; if (Pet.PetData.AnyoneCanRide == 0 && Pet.PetData.OwnerId != User.UserId) { Session.SendNotification( "You are unable to ride this horse.\nThe owner of the pet has not selected for anyone to ride it."); return; } if (Type) { if (Pet.RidingHorse) { string[] Speech2 = PlusEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("pet.alreadymounted"); var RandomSpeech2 = new Random(); Pet.Chat(Speech2[RandomSpeech2.Next(0, Speech2.Length - 1)], false); } else if (User.RidingHorse) { Session.SendNotification("You are already riding a horse!"); } else { if (Pet.Statusses.Count > 0) Pet.Statusses.Clear(); int NewX2 = User.X; int NewY2 = User.Y; Room.SendMessage(Room.GetRoomItemHandler() .UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2))); Room.SendMessage(Room.GetRoomItemHandler() .UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1)); User.MoveTo(NewX2, NewY2); Pet.ClearMovement(true); User.RidingHorse = true; Pet.RidingHorse = true; Pet.HorseID = User.VirtualId; User.HorseID = Pet.VirtualId; User.ApplyEffect(77); User.RotBody = Pet.RotBody; User.RotHead = Pet.RotHead; User.UpdateNeeded = true; Pet.UpdateNeeded = true; } } else { if (User.VirtualId == Pet.HorseID) { Pet.Statusses.Remove("sit"); Pet.Statusses.Remove("lay"); Pet.Statusses.Remove("snf"); Pet.Statusses.Remove("eat"); Pet.Statusses.Remove("ded"); Pet.Statusses.Remove("jmp"); User.RidingHorse = false; User.HorseID = 0; Pet.RidingHorse = false; Pet.HorseID = 0; User.MoveTo(new Point(User.X + 2, User.Y + 2)); User.ApplyEffect(-1); User.UpdateNeeded = true; Pet.UpdateNeeded = true; } else { Session.SendNotification("Could not dismount this horse - You are not riding it!"); } } Room.SendMessage(new PetHorseFigureInformationComposer(Pet)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) return; Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; if (!Room.CheckRights(Session, true)) return; int BotId = Packet.PopInt(); int X = Packet.PopInt(); int Y = Packet.PopInt(); if (!Room.GetGameMap().CanWalk(X, Y, false) || !Room.GetGameMap().ValidTile(X, Y)) { Session.SendNotification("You cannot place a bot here!"); return; } Bot Bot = null; if (!Session.GetHabbo().GetInventoryComponent().TryGetBot(BotId, out Bot)) return; int BotCount = 0; foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList()) { if (User == null || User.IsPet || !User.IsBot) continue; BotCount += 1; } if (BotCount >= 5 && !Session.GetHabbo().GetPermissions().HasRight("bot_place_any_override")) { Session.SendNotification("Sorry; 5 bots per room only!"); return; } //TODO: Hmm, maybe not???? using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots` SET `room_id` = '" + Room.RoomId + "', `x` = @CoordX, `y` = @CoordY WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("BotId", Bot.Id); dbClient.AddParameter("CoordX", X); dbClient.AddParameter("CoordY", Y); dbClient.RunQuery(); } List<RandomSpeech> BotSpeechList = new List<RandomSpeech>(); //TODO: Grab data? DataRow GetData = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `ai_type`,`rotation`,`walk_mode`,`automatic_chat`,`speaking_interval`,`mix_sentences`,`chat_bubble` FROM `bots` WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("BotId", Bot.Id); GetData = dbClient.getRow(); dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = @BotId"); dbClient.AddParameter("BotId", Bot.Id); DataTable BotSpeech = dbClient.getTable(); foreach (DataRow Speech in BotSpeech.Rows) { BotSpeechList.Add(new RandomSpeech(Convert.ToString(Speech["text"]), Bot.Id)); } } RoomUser BotUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Bot.Id, Session.GetHabbo().CurrentRoomId, Convert.ToString(GetData["ai_type"]), Convert.ToString(GetData["walk_mode"]), Bot.Name, "", Bot.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref BotSpeechList, "", 0, Bot.OwnerId, PlusEnvironment.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), PlusEnvironment.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null); BotUser.Chat("Hello!",false, 0); Room.GetGameMap().UpdateUserMovement(new System.Drawing.Point(X,Y), new System.Drawing.Point(X, Y), BotUser); Bot ToRemove = null; if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out ToRemove)) { Console.WriteLine("Error whilst removing Bot: " + ToRemove.Id); return; } Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Username); if (User == null) return; string NewName = Packet.PopString(); string OldName = Session.GetHabbo().Username; if (NewName == OldName) { Session.GetHabbo().ChangeName(OldName); Session.SendMessage(new UpdateUsernameComposer(NewName)); return; } if (!CanChangeName(Session.GetHabbo())) { Session.SendNotification("Oops, it appears you currently cannot change your username!"); return; } bool InUse = false; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT COUNT(0) FROM `users` WHERE `username` = @name LIMIT 1"); dbClient.AddParameter("name", NewName); InUse = dbClient.getInteger() == 1; } char[] Letters = NewName.ToLower().ToCharArray(); string AllowedCharacters = "abcdefghijklmnopqrstuvwxyz.,_-;:?!1234567890"; foreach (char Chr in Letters) { if (!AllowedCharacters.Contains(Chr)) { return; } } if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool") && NewName.ToLower().Contains("mod") || NewName.ToLower().Contains("adm") || NewName.ToLower().Contains("admin") || NewName.ToLower().Contains("m0d") || NewName.ToLower().Contains("mob") || NewName.ToLower().Contains("m0b")) return; else if (!NewName.ToLower().Contains("mod") && (Session.GetHabbo().Rank == 2 || Session.GetHabbo().Rank == 3)) return; else if (NewName.Length > 15) return; else if (NewName.Length < 3) return; else if (InUse) return; else { if (!PlusEnvironment.GetGame().GetClientManager().UpdateClientUsername(Session, OldName, NewName)) { Session.SendNotification("Oops! An issue occoured whilst updating your username."); return; } Session.GetHabbo().ChangingName = false; Room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false); Session.GetHabbo().ChangeName(NewName); Session.GetHabbo().GetMessenger().OnStatusChanged(true); Session.SendMessage(new UpdateUsernameComposer(NewName)); Room.SendMessage(new UserNameChangeComposer(Room.Id, User.VirtualId, NewName)); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `logs_client_namechange` (`user_id`,`new_name`,`old_name`,`timestamp`) VALUES ('" + Session.GetHabbo().Id + "', @name, '" + OldName + "', '" + PlusEnvironment.GetUnixTimestamp() + "')"); dbClient.AddParameter("name", NewName); dbClient.RunQuery(); } ICollection<RoomData> Rooms = Session.GetHabbo().UsersRooms; foreach (RoomData Data in Rooms) { if (Data == null) continue; Data.OwnerName = NewName; } foreach (Room UserRoom in PlusEnvironment.GetGame().GetRoomManager().GetRooms().ToList()) { if (UserRoom == null || UserRoom.RoomData.OwnerName != NewName) continue; UserRoom.OwnerName = NewName; UserRoom.RoomData.OwnerName = NewName; UserRoom.SendMessage(new RoomInfoUpdatedComposer(UserRoom.RoomId)); } PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_Name", 1); Session.SendMessage(new RoomForwardComposer(Room.Id)); } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { Session.SendNotification("Habbo Club is free for all members, enjoy!"); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int OfferId = Packet.PopInt(); DataRow Row = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `state`,`timestamp`,`total_price`,`extra_data`,`item_id`,`furni_id`,`user_id`,`limited_number`,`limited_stack` FROM `catalog_marketplace_offers` WHERE `offer_id` = @OfferId LIMIT 1"); dbClient.AddParameter("OfferId", OfferId); Row = dbClient.getRow(); } if (Row == null) { this.ReloadOffers(Session); return; } if (Convert.ToString(Row["state"]) == "2") { Session.SendNotification("Oops, this offer is no longer available."); this.ReloadOffers(Session); return; } if (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestamp() > (Convert.ToDouble(Row["timestamp"]))) { Session.SendNotification("Oops, this offer has expired.."); this.ReloadOffers(Session); return; } ItemData Item = null; if (!PlusEnvironment.GetGame().GetItemManager().GetItem(Convert.ToInt32(Row["item_id"]), out Item)) { Session.SendNotification("Item isn't in the hotel anymore."); this.ReloadOffers(Session); return; } else { if (Convert.ToInt32(Row["user_id"]) == Session.GetHabbo().Id) { Session.SendNotification("To prevent average boosting you cannot purchase your own marketplace offers."); return; } if (Convert.ToInt32(Row["total_price"]) > Session.GetHabbo().Credits) { Session.SendNotification("Oops, you do not have enough credits for this."); return; } Session.GetHabbo().Credits -= Convert.ToInt32(Row["total_price"]); Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); Item GiveItem = ItemFactory.CreateSingleItem(Item, Session.GetHabbo(), Convert.ToString(Row["extra_data"]), Convert.ToString(Row["extra_data"]), Convert.ToInt32(Row["furni_id"]), Convert.ToInt32(Row["limited_number"]), Convert.ToInt32(Row["limited_stack"])); if (GiveItem != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem); Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1)); Session.SendMessage(new Plus.Communication.Packets.Outgoing.Catalog.PurchaseOKComposer()); Session.SendMessage(new FurniListAddComposer(GiveItem)); Session.SendMessage(new FurniListUpdateComposer()); } using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `catalog_marketplace_offers` SET `state` = '2' WHERE `offer_id` = '" + OfferId + "' LIMIT 1"); int Id = 0; dbClient.SetQuery("SELECT `id` FROM catalog_marketplace_data WHERE sprite = " + Item.SpriteId + " LIMIT 1;"); Id = dbClient.getInteger(); if (Id > 0) dbClient.RunQuery("UPDATE `catalog_marketplace_data` SET `sold` = `sold` + 1, `avgprice` = (avgprice + " + Convert.ToInt32(Row["total_price"]) + ") WHERE `id` = " + Id + " LIMIT 1;"); else dbClient.RunQuery("INSERT INTO `catalog_marketplace_data` (sprite, sold, avgprice) VALUES ('" + Item.SpriteId + "', '1', '" + Convert.ToInt32(Row["total_price"]) + "')"); if (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.ContainsKey(Item.SpriteId) && PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.ContainsKey(Item.SpriteId)) { int num3 = PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts[Item.SpriteId]; int num4 = (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages[Item.SpriteId] += Convert.ToInt32(Row["total_price"])); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Remove(Item.SpriteId); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Add(Item.SpriteId, num4); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Remove(Item.SpriteId); PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Add(Item.SpriteId, num3 + 1); } else { if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.ContainsKey(Item.SpriteId)) PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketAverages.Add(Item.SpriteId, Convert.ToInt32(Row["total_price"])); if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.ContainsKey(Item.SpriteId)) PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketCounts.Add(Item.SpriteId, 1); } } } this.ReloadOffers(Session); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) return; Room Room = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) return; int ItemId = 0; string[] Data = null; string RawData = Packet.PopString(); Data = RawData.Split(' '); if (!int.TryParse(Data[0], out ItemId)) return; bool HasRights = false; if (Room.CheckRights(Session, false, true)) HasRights = true; if (!HasRights) { Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}")); return; } Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId); if (Item == null) return; if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > PlusStaticGameSettings.RoomFurnitureLimit) { Session.SendNotification("You cannot have more than " + PlusStaticGameSettings.RoomFurnitureLimit + " items in a room!"); return; } else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id && !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere")) { Session.SendNotification("You cannot place exchange items in other people's rooms!"); return; } //TODO: Make neat. switch (Item.GetBaseItem().InteractionType) { #region Interaction Types case InteractionType.MOODLIGHT: { MoodlightData moodData = Room.MoodlightData; if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null) { Session.SendNotification("You can only have one background moodlight per room!"); return; } break; } case InteractionType.TONER: { TonerData tonerData = Room.TonerData; if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null) { Session.SendNotification("You can only have one background toner per room!"); return; } break; } case InteractionType.HOPPER: { if (Room.GetRoomItemHandler().HopperCount > 0) { Session.SendNotification("You can only have one hopper per room!"); return; } break; } case InteractionType.TENT: case InteractionType.TENT_SMALL: { Room.AddTent(Item.Id); break; } #endregion } if (!Item.IsWallItem) { if (Data.Length < 4) return; int X = 0; int Y = 0; int Rotation = 0; if (!int.TryParse(Data[1], out X)) { return; } if (!int.TryParse(Data[2], out Y)) { return; } if (!int.TryParse(Data[3], out Rotation)) { return; } Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room); if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true)) { Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId); if (Session.GetHabbo().Id == Room.OwnerId) PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false); if (RoomItem.IsWired) { try { Room.GetWired().LoadWiredBox(RoomItem); } catch { Console.WriteLine(Item.GetBaseItem().InteractionType); } } } else { Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}")); return; } } else if (Item.IsWallItem) { string[] CorrectedData = new string[Data.Length - 1]; for (int i = 1; i < Data.Length; i++) { CorrectedData[i - 1] = Data[i]; } string WallPos = string.Empty; if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out WallPos)) { try { Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room); if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem)) { Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId); if (Session.GetHabbo().Id == Room.OwnerId) PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false); } } catch { Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}")); return; } } else { Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}")); return; } } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { int pId = Packet.PopInt(); bool isConfirmed = Packet.PopBoolean(); Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; Item Item = Room.GetRoomItemHandler().GetItem(pId); if (Item == null || Item.GetBaseItem() == null || Item.GetBaseItem().InteractionType != InteractionType.LOVELOCK) return; int UserOneId = Item.InteractingUser; int UserTwoId = Item.InteractingUser2; RoomUser UserOne = Room.GetRoomUserManager().GetRoomUserByHabbo(UserOneId); RoomUser UserTwo = Room.GetRoomUserManager().GetRoomUserByHabbo(UserTwoId); if(UserOne == null && UserTwo == null) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; Session.SendNotification("Your partner has left the room or has cancelled the love lock."); return; } else if(UserOne.GetClient() == null || UserTwo.GetClient() == null) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; Session.SendNotification("Your partner has left the room or has cancelled the love lock."); return; } else if(UserOne == null) { UserTwo.CanWalk = true; UserTwo.GetClient().SendNotification("Your partner has left the room or has cancelled the love lock."); UserTwo.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if(UserTwo == null) { UserOne.CanWalk = true; UserOne.GetClient().SendNotification("Your partner has left the room or has cancelled the love lock."); UserOne.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if(Item.ExtraData.Contains(Convert.ToChar(5).ToString())) { UserTwo.CanWalk = true; UserTwo.GetClient().SendNotification("It appears this love lock has already been locked."); UserTwo.LLPartner = 0; UserOne.CanWalk = true; UserOne.GetClient().SendNotification("It appears this love lock has already been locked."); UserOne.LLPartner = 0; Item.InteractingUser = 0; Item.InteractingUser2 = 0; return; } else if(!isConfirmed) { Item.InteractingUser = 0; Item.InteractingUser2 = 0; UserOne.LLPartner = 0; UserTwo.LLPartner = 0; UserOne.CanWalk = true; UserTwo.CanWalk = true; return; } else { if(UserOneId == Session.GetHabbo().Id) { Session.SendMessage(new LoveLockDialogueSetLockedMessageComposer(pId)); UserOne.LLPartner = UserTwoId; } else if(UserTwoId == Session.GetHabbo().Id) { Session.SendMessage(new LoveLockDialogueSetLockedMessageComposer(pId)); UserTwo.LLPartner = UserOneId; } if (UserOne.LLPartner == 0 || UserTwo.LLPartner == 0) return; else { Item.ExtraData = "1" + (char)5 + UserOne.GetUsername() + (char)5 + UserTwo.GetUsername() + (char)5 + UserOne.GetClient().GetHabbo().Look + (char)5 + UserTwo.GetClient().GetHabbo().Look + (char)5 + DateTime.Now.ToString("dd/MM/yyyy"); Item.InteractingUser = 0; Item.InteractingUser2 = 0; UserOne.LLPartner = 0; UserTwo.LLPartner = 0; Item.UpdateState(true, true); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE items SET extra_data = @extraData WHERE id = @ID LIMIT 1"); dbClient.AddParameter("extraData", Item.ExtraData); dbClient.AddParameter("ID", Item.Id); dbClient.RunQuery(); } UserOne.GetClient().SendMessage(new LoveLockDialogueCloseMessageComposer(pId)); UserTwo.GetClient().SendMessage(new LoveLockDialogueCloseMessageComposer(pId)); UserOne.CanWalk = true; UserTwo.CanWalk = true; UserOne = null; UserTwo = null; } } }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session.GetHabbo().Credits < PlusStaticGameSettings.GroupPurchaseAmount) { Session.SendMessage(new BroadcastMessageAlertComposer("A group costs " + PlusStaticGameSettings.GroupPurchaseAmount + " credits! You only have " + Session.GetHabbo().Credits + "!")); return; } else { Session.GetHabbo().Credits -= PlusStaticGameSettings.GroupPurchaseAmount; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } String Name = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString()); String Description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString()); int RoomId = Packet.PopInt(); int Colour1 = Packet.PopInt(); int Colour2 = Packet.PopInt(); int groupID3 = Packet.PopInt(); int groupID4 = Packet.PopInt(); int groupID5 = Packet.PopInt(); int groupID6 = Packet.PopInt(); int groupID7 = Packet.PopInt(); int groupID8 = Packet.PopInt(); int groupID9 = Packet.PopInt(); int groupID10 = Packet.PopInt(); int groupID11 = Packet.PopInt(); int groupID12 = Packet.PopInt(); int groupID13 = Packet.PopInt(); int groupID14 = Packet.PopInt(); int groupID15 = Packet.PopInt(); int groupID16 = Packet.PopInt(); int groupID17 = Packet.PopInt(); int groupID18 = Packet.PopInt(); RoomData Room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(RoomId); if (Room == null || Room.OwnerId != Session.GetHabbo().Id || Room.Group != null) return; string Base = "b" + ((groupID4 < 10) ? "0" + groupID4.ToString() : groupID4.ToString()) + ((groupID5 < 10) ? "0" + groupID5.ToString() : groupID5.ToString()) + groupID6; string Symbol1 = "s" + ((groupID7 < 10) ? "0" + groupID7.ToString() : groupID7.ToString()) + ((groupID8 < 10) ? "0" + groupID8.ToString() : groupID8.ToString()) + groupID9; string Symbol2 = "s" + ((groupID10 < 10) ? "0" + groupID10.ToString() : groupID10.ToString()) + ((groupID11 < 10) ? "0" + groupID11.ToString() : groupID11.ToString()) + groupID12; string Symbol3 = "s" + ((groupID13 < 10) ? "0" + groupID13.ToString() : groupID13.ToString()) + ((groupID14 < 10) ? "0" + groupID14.ToString() : groupID14.ToString()) + groupID15; string Symbol4 = "s" + ((groupID16 < 10) ? "0" + groupID16.ToString() : groupID16.ToString()) + ((groupID17 < 10) ? "0" + groupID17.ToString() : groupID17.ToString()) + groupID18; Symbol1 = PlusEnvironment.GetGame().GetGroupManager().CheckActiveSymbol(Symbol1); Symbol2 = PlusEnvironment.GetGame().GetGroupManager().CheckActiveSymbol(Symbol2); Symbol3 = PlusEnvironment.GetGame().GetGroupManager().CheckActiveSymbol(Symbol3); Symbol4 = PlusEnvironment.GetGame().GetGroupManager().CheckActiveSymbol(Symbol4); string Badge = Base + Symbol1 + Symbol2 + Symbol3 + Symbol4; Group Group = null; if (!PlusEnvironment.GetGame().GetGroupManager().TryCreateGroup(Session.GetHabbo(), Name, Description, RoomId, Badge, Colour1, Colour2, out Group)) { Session.SendNotification("An error occured whilst trying to create this group.\n\nTry again. If you get this message more than once, report it at the link below.\r\rhttp://boonboards.com"); return; } Session.SendMessage(new PurchaseOKComposer()); Room.Group = Group; if (Session.GetHabbo().CurrentRoomId != Room.Id) Session.SendMessage(new RoomForwardComposer(Room.Id)); Session.SendMessage(new NewGroupInfoComposer(RoomId, Group.Id)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) return; Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) return; int PresentId = Packet.PopInt(); Item Present = Room.GetRoomItemHandler().GetItem(PresentId); if (Present == null) return; if (Present.UserID != Session.GetHabbo().Id) return; DataRow Data = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `base_id`,`extra_data` FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1"); Data = dbClient.getRow(); } if (Data == null) { Session.SendNotification("Oops! Appears there was a bug with this gift.\nWe'll just get rid of it for you."); Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id, false); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Present.Id + "' LIMIT 1"); dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id); return; } int PurchaserId = 0; if (!int.TryParse(Present.ExtraData.Split(Convert.ToChar(5))[2], out PurchaserId)) { Session.SendNotification("Oops! Appears there was a bug with this gift.\nWe'll just get rid of it for you."); Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id, false); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Present.Id + "' LIMIT 1"); dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id); return; } UserCache Purchaser = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(PurchaserId); if (Purchaser == null) { Session.SendNotification("Oops! Appears there was a bug with this gift.\nWe'll just get rid of it for you."); Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id, false); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Present.Id + "' LIMIT 1"); dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id); return; } ItemData BaseItem = null; if (!PlusEnvironment.GetGame().GetItemManager().GetItem(Convert.ToInt32(Data["base_id"]), out BaseItem)) { Session.SendNotification("Oops, it appears that the item within the gift is no longer in the hotel!"); Room.GetRoomItemHandler().RemoveFurniture(null, Present.Id, false); using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("DELETE FROM `items` WHERE `id` = '" + Present.Id + "' LIMIT 1"); dbClient.RunQuery("DELETE FROM `user_presents` WHERE `item_id` = '" + Present.Id + "' LIMIT 1"); } Session.GetHabbo().GetInventoryComponent().RemoveItem(Present.Id); return; } Present.MagicRemove = true; Room.SendMessage(new ObjectUpdateComposer(Present, Convert.ToInt32(Session.GetHabbo().Id))); Thread thread = new Thread(() => FinishOpenGift(Session, BaseItem, Present, Room, Data)); thread.Start(); }