public void Parse(GameClient session, ClientPacket packet) { if (PlusEnvironment.GetSettingsManager().TryGetValue("catalog.enabled") != "1") { session.SendNotification("The hotel managers have disabled the catalogue"); return; } var pageId = packet.PopInt(); var itemId = packet.PopInt(); var extraData = packet.PopString(); var amount = packet.PopInt(); CatalogPage page; if (!PlusEnvironment.GetGame().GetCatalog().TryGetPage(pageId, out page)) { return; } if (!page.Enabled || !page.Visible || page.MinimumRank > session.GetHabbo().Rank || page.MinimumRank > session.GetHabbo().VipRank&& session.GetHabbo().Rank == 1) { return; } if (!page.Items.TryGetValue(itemId, out var item)) { if (page.ItemOffers.ContainsKey(itemId)) { item = page.ItemOffers[itemId]; if (item == null) { return; } } else { return; } } if (amount < 1 || amount > 100 || !item.HaveOffer) { amount = 1; } var amountPurchase = item.Amount > 1 ? item.Amount : amount; var totalCreditsCost = amount > 1 ? item.CostCredits * amount - (int)Math.Floor((double)amount / 6) * item.CostCredits : item.CostCredits; var totalPixelCost = amount > 1 ? item.CostPixels * amount - (int)Math.Floor((double)amount / 6) * item.CostPixels : item.CostPixels; var totalDiamondCost = amount > 1 ? item.CostDiamonds * amount - (int)Math.Floor((double)amount / 6) * item.CostDiamonds : item.CostDiamonds; if (session.GetHabbo().Credits < totalCreditsCost || session.GetHabbo().Duckets < totalPixelCost || session.GetHabbo().Diamonds < totalDiamondCost) { return; } var limitedEditionSells = 0; var limitedEditionStack = 0; switch (item.Data.InteractionType) { case InteractionType.None: extraData = ""; break; case InteractionType.GuildItem: case InteractionType.GuildGate: break; #region Pet handling case InteractionType.Pet: try { var bits = extraData.Split('\n'); var petName = bits[0]; var race = bits[1]; var 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 (Exception e) { ExceptionLogger.LogException(e); return; } break; #endregion case InteractionType.Floor: case InteractionType.Wallpaper: case InteractionType.Landscape: double number = 0; try { if (string.IsNullOrEmpty(extraData)) { number = 0; } else { number = double.Parse(extraData, PlusEnvironment.CultureInfo); } } catch (Exception e) { ExceptionLogger.LogException(e); } extraData = number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.Postit: extraData = "FFFF33"; break; case InteractionType.Moodlight: extraData = "1,1,1,#000000,255"; break; case InteractionType.Trophy: extraData = session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + extraData; break; case InteractionType.Mannequin: extraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin"; break; case InteractionType.BadgeDisplay: if (!session.GetHabbo().GetBadgeComponent().HasBadge(extraData)) { session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge.")); return; } extraData = extraData + Convert.ToChar(9) + session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.Badge: { if (session.GetHabbo().GetBadgeComponent().HasBadge(item.Data.ItemName)) { session.SendPacket(new PurchaseErrorComposer(1)); return; } break; } default: extraData = ""; break; } if (item.IsLimited) { if (item.LimitedEditionStack <= item.LimitedEditionSells) { session.SendNotification("This item has sold out!\n\n" + "Please note, you have not recieved another item (You have also not been charged for it!)"); session.SendPacket(new CatalogUpdatedComposer()); session.SendPacket(new PurchaseOkComposer()); return; } item.LimitedEditionSells++; using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", item.LimitedEditionSells); dbClient.AddParameter("itemId", item.Id); dbClient.RunQuery(); limitedEditionSells = item.LimitedEditionSells; limitedEditionStack = item.LimitedEditionStack; } } if (item.CostCredits > 0) { session.GetHabbo().Credits -= totalCreditsCost; session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits)); } if (item.CostPixels > 0) { session.GetHabbo().Duckets -= totalPixelCost; session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, session.GetHabbo().Duckets)); //Love you, Tom. } if (item.CostDiamonds > 0) { session.GetHabbo().Diamonds -= totalDiamondCost; session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Diamonds, 0, 5)); } Item newItem = null; switch (item.Data.Type.ToString().ToLower()) { default: var generatedGenericItems = new List <Item>(); switch (item.Data.InteractionType) { default: if (amountPurchase > 1) { var items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, 0, limitedEditionSells, limitedEditionStack); if (newItem != null) { generatedGenericItems.Add(newItem); } } break; case InteractionType.GuildGate: case InteractionType.GuildItem: case InteractionType.GuildForum: if (amountPurchase > 1) { var items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase, Convert.ToInt32(extraData)); if (items != null) { generatedGenericItems.AddRange(items); } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, Convert.ToInt32(extraData)); if (newItem != null) { generatedGenericItems.Add(newItem); } } break; case InteractionType.Arrow: case InteractionType.Teleport: for (var i = 0; i < amountPurchase; i++) { var teleItems = ItemFactory.CreateTeleporterItems(item.Data, session.GetHabbo()); if (teleItems != null) { generatedGenericItems.AddRange(teleItems); } } break; case InteractionType.Moodlight: { if (amountPurchase > 1) { var items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); foreach (var I in items) { ItemFactory.CreateMoodlightData(I); } } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData); if (newItem != null) { generatedGenericItems.Add(newItem); ItemFactory.CreateMoodlightData(newItem); } } } break; case InteractionType.Toner: { if (amountPurchase > 1) { var items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); foreach (var I in items) { ItemFactory.CreateTonerData(I); } } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData); if (newItem != null) { generatedGenericItems.Add(newItem); ItemFactory.CreateTonerData(newItem); } } } break; case InteractionType.Deal: { CatalogDeal deal = null; if (PlusEnvironment.GetGame().GetCatalog().TryGetDeal(item.Data.BehaviourData, out deal)) { foreach (var catalogItem in deal.ItemDataList.ToList()) { var items = ItemFactory.CreateMultipleItems(catalogItem.Data, session.GetHabbo(), "", amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); } } } break; } case InteractionType.Roomdeal: { CatalogDeal deal; if (PlusEnvironment.GetGame().GetCatalog().TryGetDeal(item.Data.BehaviourData, out deal)) { var room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(deal.RoomId); if (room == null) { session.SendNotification("There was an error loading this Room Bundle, if this happens again please contact hotel management!"); return; } var newRoom = PlusEnvironment.GetGame().GetRoomManager().CreateRoom(session, room.Name, room.Description, room.ModelName, room.Category, 10, room.TradeSettings, room.Wallpaper, room.Floor, room.Landscape, room.WallThickness, room.FloorThickness); if (newRoom == null) { return; } var myRoom = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(newRoom.Id); if (myRoom != null) { var items = ItemLoader.GetItemsForRoom(deal.RoomId, room); Item teleLink = null; foreach (var furni in items) { if (furni.Data.InteractionType == InteractionType.Teleport) { if (teleLink == null) { var teleItems = ItemFactory.CreateTeleporterItems(furni.Data, session.GetHabbo()); if (teleItems != null && teleItems.ToList().Count > 1) { myRoom.GetRoomItemHandler().SetFloorItem(session, teleItems[0], furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); teleLink = teleItems[1]; } } else { myRoom.GetRoomItemHandler().SetFloorItem(session, teleLink, furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); teleLink = null; } } else { newItem = ItemFactory.CreateSingleItemNullable(furni.Data, session.GetHabbo(), furni.ExtraData, furni.GroupId); if (newItem != null) { if (newItem.IsWallItem) { newItem.WallCoord = furni.WallCoord; myRoom.GetRoomItemHandler().SetWallItem(session, newItem); } else { myRoom.GetRoomItemHandler().SetFloorItem(session, newItem, furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); } } } } session.GetHabbo().PrepareRoom(myRoom.Id, ""); } } break; } } foreach (var purchasedItem in generatedGenericItems) { if (session.GetHabbo().GetInventoryComponent().TryAddItem(purchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); session.SendPacket(new FurniListNotificationComposer(purchasedItem.Id, 1)); } } break; case "e": AvatarEffect effect = null; if (session.GetHabbo().Effects().HasEffect(item.Data.SpriteId)) { effect = session.GetHabbo().Effects().GetEffectNullable(item.Data.SpriteId); if (effect != null) { effect.AddToQuantity(); } } else { effect = AvatarEffectFactory.CreateNullable(session.GetHabbo(), item.Data.SpriteId, 3600); } if (effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { session.SendPacket(new AvatarEffectAddedComposer(item.Data.SpriteId, 3600)); } break; case "r": var bot = BotUtility.CreateBot(item.Data, session.GetHabbo().Id); if (bot != null) { session.GetHabbo().GetInventoryComponent().TryAddBot(bot); session.SendPacket(new BotInventoryComposer(session.GetHabbo().GetInventoryComponent().GetBots())); session.SendPacket(new FurniListNotificationComposer(bot.Id, 5)); } else { session.SendNotification("Oops! There was an error whilst purchasing this bot. It seems that there is no bot data for the bot!"); } break; case "b": { session.GetHabbo().GetBadgeComponent().GiveBadge(item.Data.ItemName, true, session); session.SendPacket(new FurniListNotificationComposer(0, 4)); break; } case "p": { var petData = extraData.Split('\n'); var generatedPet = PetUtility.CreatePet(session.GetHabbo().Id, petData[0], item.Data.BehaviourData, petData[1], petData[2]); if (generatedPet != null) { session.GetHabbo().GetInventoryComponent().TryAddPet(generatedPet); session.SendPacket(new FurniListNotificationComposer(generatedPet.PetId, 3)); session.SendPacket(new PetInventoryComposer(session.GetHabbo().GetInventoryComponent().GetPets())); ItemData petFood = null; if (PlusEnvironment.GetGame().GetItemManager().GetItem(320, out petFood)) { var food = ItemFactory.CreateSingleItemNullable(petFood, session.GetHabbo(), ""); if (food != null) { session.GetHabbo().GetInventoryComponent().TryAddItem(food); session.SendPacket(new FurniListNotificationComposer(food.Id, 1)); } } } break; } } BadgeDefinition badge; if (!string.IsNullOrEmpty(item.Badge) && PlusEnvironment.GetGame().GetBadgeManager().TryGetBadge(item.Badge, out badge) && (string.IsNullOrEmpty(badge.RequiredRight) || session.GetHabbo().GetPermissions().HasRight(badge.RequiredRight))) { session.GetHabbo().GetBadgeComponent().GiveBadge(badge.Code, true, session); } session.SendPacket(new PurchaseOkComposer(item, item.Data)); session.SendPacket(new FurniListUpdateComposer()); }
public void Parse(GameClient Session, ClientPacket Packet) { if (PlusEnvironment.GetDBConfig().DBData["catalogue_enabled"] != "1") { Session.SendNotification("The hotel managers have disabled the catalogue"); return; } int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string ExtraData = Packet.PopString(); int Amount = Packet.PopInt(); 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 (Amount < 1 || Amount > 100 || !Item.HaveOffer) { Amount = 1; } int AmountPurchase = Item.Amount > 1 ? Item.Amount : Amount; int TotalCreditsCost = Amount > 1 ? ((Item.CostCredits * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostCredits)) : Item.CostCredits; int TotalPixelCost = Amount > 1 ? ((Item.CostPixels * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostPixels)) : Item.CostPixels; int TotalDiamondCost = Amount > 1 ? ((Item.CostDiamonds * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDiamonds)) : Item.CostDiamonds; if (Session.GetHabbo().Credits < TotalCreditsCost || Session.GetHabbo().Duckets < TotalPixelCost || Session.GetHabbo().Diamonds < TotalDiamondCost) { return; } int LimitedEditionSells = 0; int LimitedEditionStack = 0; #region Create the extradata switch (Item.Data.InteractionType) { case InteractionType.NONE: ExtraData = ""; break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: 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 = ExtraData.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 (Exception e) { Logging.LogException(e.ToString()); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(ExtraData)) { Number = 0; } else { Number = Double.Parse(ExtraData, PlusEnvironment.CultureInfo); } } catch (Exception e) { Logging.HandleException(e, "Catalog.HandlePurchase: " + ExtraData); } ExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ExtraData; break; case InteractionType.MANNEQUIN: ExtraData = "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(ExtraData)) { Session.SendMessage(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge.")); return; } ExtraData = ExtraData + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Data.ItemName)) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } break; } default: ExtraData = ""; break; } #endregion if (Item.IsLimited) { if (Item.LimitedEditionStack <= Item.LimitedEditionSells) { Session.SendNotification("This item has sold out!\n\n" + "Please note, you have not recieved another item (You have also not been charged for it!)"); Session.SendMessage(new CatalogUpdatedComposer()); Session.SendMessage(new PurchaseOKComposer()); return; } Item.LimitedEditionSells++; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.RunQuery("UPDATE `catalog_items` SET `limited_sells` = '" + Item.LimitedEditionSells + "' WHERE `id` = '" + Item.Id + "' LIMIT 1"); LimitedEditionSells = Item.LimitedEditionSells; LimitedEditionStack = Item.LimitedEditionStack; } } if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= TotalCreditsCost; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostPixels > 0) { Session.GetHabbo().Duckets -= TotalPixelCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= TotalDiamondCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } Item NewItem = null; switch (Item.Data.Type.ToString().ToLower()) { default: List <Item> GeneratedGenericItems = new List <Item>(); switch (Item.Data.InteractionType) { default: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, 0, LimitedEditionSells, LimitedEditionStack); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.GUILD_GATE: case InteractionType.GUILD_ITEM: case InteractionType.GUILD_FORUM: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase, Convert.ToInt32(ExtraData)); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, Convert.ToInt32(ExtraData)); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.ARROW: case InteractionType.TELEPORT: for (int i = 0; i < AmountPurchase; i++) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(Item.Data, Session.GetHabbo()); if (TeleItems != null) { GeneratedGenericItems.AddRange(TeleItems); } } break; case InteractionType.MOODLIGHT: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateMoodlightData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateMoodlightData(NewItem); } } } break; case InteractionType.TONER: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateTonerData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateTonerData(NewItem); } } } break; case InteractionType.DEAL: { //Fetch the deal where the ID is this items ID. var DealItems = (from d in Page.Deals.Values.ToList() where d.Id == Item.Id select d); //This bit, iterating ONE item? How can I make this simpler foreach (CatalogDeal DealItem in DealItems) { //Here I loop the DealItems ItemDataList. foreach (CatalogItem CatalogItem in DealItem.ItemDataList.ToList()) { List <Item> Items = ItemFactory.CreateMultipleItems(CatalogItem.Data, Session.GetHabbo(), "", AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } } break; } } foreach (Item PurchasedItem in GeneratedGenericItems) { if (Session.GetHabbo().GetInventoryComponent().TryAddItem(PurchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); Session.SendMessage(new FurniListNotificationComposer(PurchasedItem.Id, 1)); } } break; case "e": AvatarEffect Effect = null; if (Session.GetHabbo().Effects().HasEffect(Item.Data.SpriteId)) { Effect = Session.GetHabbo().Effects().GetEffectNullable(Item.Data.SpriteId); if (Effect != null) { Effect.AddToQuantity(); } } else { Effect = AvatarEffectFactory.CreateNullable(Session.GetHabbo(), Item.Data.SpriteId, 3600); } if (Effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { Session.SendMessage(new AvatarEffectAddedComposer(Item.Data.SpriteId, 3600)); } break; case "r": Bot Bot = BotUtility.CreateBot(Item.Data, Session.GetHabbo().Id); if (Bot != null) { Session.GetHabbo().GetInventoryComponent().TryAddBot(Bot); Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); Session.SendMessage(new FurniListNotificationComposer(Bot.Id, 5)); } else { Session.SendNotification("Oops! There was an error whilst purchasing this bot. It seems that there is no bot data for the bot!"); } break; case "b": { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Data.ItemName, true, Session); Session.SendMessage(new FurniListNotificationComposer(0, 4)); break; } case "p": { switch (Item.Data.InteractionType) { #region Pets #region Pet 0 case InteractionType.pet0: string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = PetUtility.CreatePet(Session.GetHabbo().Id, PetData[0], 0, PetData[1], PetData[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet); break; #endregion #region Pet 1 case InteractionType.pet1: string[] PetData1 = ExtraData.Split('\n'); Pet GeneratedPet1 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData1[0], 1, PetData1[1], PetData1[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet1); break; #endregion #region Pet 2 case InteractionType.pet2: string[] PetData5 = ExtraData.Split('\n'); Pet GeneratedPet5 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData5[0], 2, PetData5[1], PetData5[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet5); break; #endregion #region Pet 3 case InteractionType.pet3: string[] PetData2 = ExtraData.Split('\n'); Pet GeneratedPet2 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData2[0], 3, PetData2[1], PetData2[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet2); break; #endregion #region Pet 4 case InteractionType.pet4: string[] PetData3 = ExtraData.Split('\n'); Pet GeneratedPet3 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData3[0], 4, PetData3[1], PetData3[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet3); break; #endregion #region Pet 5 case InteractionType.pet5: string[] PetData7 = ExtraData.Split('\n'); Pet GeneratedPet7 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData7[0], 5, PetData7[1], PetData7[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet7); break; #endregion #region Pet 6 (wrong?) case InteractionType.pet6: string[] PetData4 = ExtraData.Split('\n'); Pet GeneratedPet4 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData4[0], 6, PetData4[1], PetData4[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet4); break; #endregion #region Pet 7 (wrong?) case InteractionType.pet7: string[] PetData6 = ExtraData.Split('\n'); Pet GeneratedPet6 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData6[0], 7, PetData6[1], PetData6[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet6); break; #endregion #region Pet 8 case InteractionType.pet8: string[] PetData8 = ExtraData.Split('\n'); Pet GeneratedPet8 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData8[0], 8, PetData8[1], PetData8[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet8); break; #endregion #region Pet 8 case InteractionType.pet9: string[] PetData9 = ExtraData.Split('\n'); Pet GeneratedPet9 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData9[0], 9, PetData9[1], PetData9[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet9); break; #endregion #region Pet 10 case InteractionType.pet10: string[] PetData10 = ExtraData.Split('\n'); Pet GeneratedPet10 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData10[0], 10, PetData10[1], PetData10[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet10); break; #endregion #region Pet 11 case InteractionType.pet11: string[] PetData11 = ExtraData.Split('\n'); Pet GeneratedPet11 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData11[0], 11, PetData11[1], PetData11[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet11); break; #endregion #region Pet 12 case InteractionType.pet12: string[] PetData12 = ExtraData.Split('\n'); Pet GeneratedPet12 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData12[0], 12, PetData12[1], PetData12[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet12); break; #endregion #region Pet 13 case InteractionType.pet13: //Caballo - Horse string[] PetData13 = ExtraData.Split('\n'); Pet GeneratedPet13 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData13[0], 13, PetData13[1], PetData13[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet13); break; #endregion #region Pet 14 case InteractionType.pet14: string[] PetData14 = ExtraData.Split('\n'); Pet GeneratedPet14 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData14[0], 14, PetData14[1], PetData14[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet14); break; #endregion #region Pet 15 case InteractionType.pet15: string[] PetData15 = ExtraData.Split('\n'); Pet GeneratedPet15 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData15[0], 15, PetData15[1], PetData15[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet15); break; #endregion #region Pet 16 case InteractionType.pet16: // Mascota Agregada string[] PetData16 = ExtraData.Split('\n'); Pet GeneratedPet16 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData16[0], 16, PetData16[1], PetData16[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet16); break; #endregion #region Pet 17 case InteractionType.pet17: // Mascota Agregada string[] PetData17 = ExtraData.Split('\n'); Pet GeneratedPet17 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData17[0], 17, PetData17[1], PetData17[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet17); break; #endregion #region Pet 18 case InteractionType.pet18: // Mascota Agregada string[] PetData18 = ExtraData.Split('\n'); Pet GeneratedPet18 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData18[0], 18, PetData18[1], PetData18[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet18); break; #endregion #region Pet 19 case InteractionType.pet19: // Mascota Agregada string[] PetData19 = ExtraData.Split('\n'); Pet GeneratedPet19 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData19[0], 19, PetData19[1], PetData19[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet19); break; #endregion #region Pet 20 case InteractionType.pet20: // Mascota Agregada string[] PetData20 = ExtraData.Split('\n'); Pet GeneratedPet20 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData20[0], 20, PetData20[1], PetData20[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet20); break; #endregion #region Pet 21 case InteractionType.pet21: // Mascota Agregada string[] PetData21 = ExtraData.Split('\n'); Pet GeneratedPet21 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData21[0], 21, PetData21[1], PetData21[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet21); break; #endregion #region Pet 22 case InteractionType.pet22: // Mascota Agregada string[] PetData22 = ExtraData.Split('\n'); Pet GeneratedPet22 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData22[0], 22, PetData22[1], PetData22[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet22); break; #endregion #region Pet 28 case InteractionType.pet28: // Mascota Agregada string[] PetData28 = ExtraData.Split('\n'); Pet GeneratedPet28 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData28[0], 28, PetData28[1], PetData28[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet28); break; #endregion #region Pet 29 case InteractionType.pet29: string[] PetData29 = ExtraData.Split('\n'); Pet GeneratedPet29 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData29[0], 29, PetData29[1], PetData29[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet29); break; #endregion #region Pet 30 case InteractionType.pet30: string[] PetData30 = ExtraData.Split('\n'); Pet GeneratedPet30 = PetUtility.CreatePet(Session.GetHabbo().Id, PetData30[0], 30, PetData30[1], PetData30[2]); Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet30); break; #endregion #endregion } Session.SendMessage(new FurniListNotificationComposer(0, 3)); Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); 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)); } } break; } } Session.SendMessage(new PurchaseOKComposer(Item, Item.Data)); Session.SendMessage(new FurniListUpdateComposer()); }
public void Parse(GameClient Session, ClientPacket Packet) { ICollection <Item> FloorItems = Session.GetHabbo().GetInventoryComponent().GetFloorItems(); ICollection <Item> WallItems = Session.GetHabbo().GetInventoryComponent().GetWallItems(); if (BiosEmuThiago.GetGame().GetSettingsManager().TryGetValue("catalog.enabled") != "1") { Session.SendNotification("Os gerentes do Hotel desabilitaram o catalogo!"); return; } int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string ExtraData = Packet.PopString(); int Amount = Packet.PopInt(); if (!BiosEmuThiago.GetGame().GetCatalog().TryGetPage(PageId, out CatalogPage Page)) { return; } if (!Page.Enabled || !Page.Visible || Page.MinimumRank > Session.GetHabbo().Rank || (Page.MinimumVIP > Session.GetHabbo().VIPRank&& Session.GetHabbo().Rank == 1)) { return; } if (!Page.Items.TryGetValue(ItemId, out CatalogItem Item)) { if (Page.ItemOffers.ContainsKey(ItemId)) { Item = Page.ItemOffers[ItemId]; if (Item == null) { return; } } else { return; } } if (Session.GetHabbo().Rank > 0) { DataRow presothiago = null; using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT Presidio FROM users WHERE id = '" + Session.GetHabbo().Id + "'"); presothiago = dbClient.getRow(); } if (Convert.ToBoolean(presothiago["Presidio"]) == true) { if (Session.GetHabbo().Rank > 0) { string thiago = Session.GetHabbo().Look; Session.SendMessage(new RoomNotificationComposer("police_announcement", "message", "Você esta preso e não pode comprar no catálogo.")); return; } } } ItemData baseItem = Item.GetBaseItem(Item.ItemId); if (baseItem != null) { if (baseItem.InteractionType == InteractionType.club_1_month || baseItem.InteractionType == InteractionType.club_3_month || baseItem.InteractionType == InteractionType.club_6_month) { int Months = 0; switch (baseItem.InteractionType) { case InteractionType.club_1_month: Months = 1; break; case InteractionType.club_3_month: Months = 3; break; case InteractionType.club_6_month: Months = 6; break; } int num = num = 31 * Months; if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Session.GetHabbo().GetClubManager().AddOrExtendSubscription("habbo_vip", num * 24 * 3600, Session); Session.GetHabbo().GetBadgeComponent().GiveBadge("HC1", true, Session); Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } } if (baseItem.InteractionType == InteractionType.namecolor) { if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `name_color` = '#" + Item.Name + "' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.GetHabbo().chatHTMLColour = "#" + Item.Name; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.prefixname) { if (ExtraData.Length > 6 || ExtraData.Length == 0 || ExtraData.Length < 0) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper("Você deve digitar um código de 1 a 6 caracteres para adquirir.", 34); return; } if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override") && BiosEmuThiago.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(ExtraData, out string word)) { // Todos os direitos resevados ao criador do comando: Thiago Araujo (Plus Emulador) Servidores de SAO // Comando editaveu abaixo mais cuidado pra não faze merda Session.GetHabbo().BannedPhraseCount++; if (Session.GetHabbo().BannedPhraseCount >= 1) { Session.GetHabbo().TimeMuted = 10; Session.SendNotification("Você foi silenciado, um moderador vai rever o seu caso, aparentemente, você nomeou um hotel! Não continue divulgando ser for um hotel pois temos ante divulgação - Aviso<font size =\"11\" color=\"#fc0a3a\"> <b>" + Session.GetHabbo().BannedPhraseCount + "/5</b></font> Se chega ao numero 5/5 você sera banido automaticamente"); BiosEmuThiago.GetGame().GetClientManager().StaffAlert(new RoomNotificationComposer("Alerta publicitário:", "Atenção colaboradores, o usuário <b>" + Session.GetHabbo().Username + "</b> divulgou um link de um site ou hotel na compra de uma tag na loja, você poderia investigar? so click no botão abaixo *Ir ao Quarto*. <i> a palavra dita:<font size =\"11\" color=\"#f40909\"> <b> " + ExtraData + "</b></font></i> dentro de um quarto\r\n" + "- Nome do usuário: <font size =\"11\" color=\"#0b82c6\"> <b>" + Session.GetHabbo().Username + "</b>", "", "Ir ao Quarto", "event:navigator/goto/" + Session.GetHabbo().CurrentRoomId)); } if (Session.GetHabbo().BannedPhraseCount >= 5) { BiosEmuThiago.GetGame().GetModerationManager().BanUser("BiosEmulador ante divulgação", HabboHotel.Moderation.ModerationBanType.USERNAME, Session.GetHabbo().Username, "Banido por spam com a frase (" + ExtraData + ")", (BiosEmuThiago.GetUnixTimestamp() + 78892200)); Session.Disconnect(); return; } Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "Mensagem inapropiada no " + BiosEmuThiago.HotelName + " . Estamos investigando o que você falou" + " " + Session.GetHabbo().Username + " " + "no quarto!")); return; } if (ExtraData.ToUpper().Contains("ADM") || ExtraData.ToUpper().Contains("ADMIN") || ExtraData.ToUpper().Contains("GER") || ExtraData.ToUpper().Contains("DONO") || ExtraData.ToUpper().Contains("RANK") || ExtraData.ToUpper().Contains("MNG") || ExtraData.ToUpper().Contains("MOD") || ExtraData.ToUpper().Contains("STAFF") || ExtraData.ToUpper().Contains("ALFA") || ExtraData.ToUpper().Contains("ALPHA") || ExtraData.ToUpper().Contains("HELPER") || ExtraData.ToUpper().Contains("GM") || ExtraData.ToUpper().Contains("CEO") || ExtraData.ToUpper().Contains("ROOKIE") || ExtraData.ToUpper().Contains("M0D") || ExtraData.ToUpper().Contains("DEV") || ExtraData.ToUpper().Contains("OWNR") || ExtraData.ToUpper().Contains("FUNDADOR") || ExtraData.ToUpper().Contains("<") || ExtraData.ToUpper().Contains(">") || ExtraData.ToUpper().Contains("POLICIAL") || ExtraData.ToUpper().Contains("policial") || ExtraData.ToUpper().Contains("ajudante") || ExtraData.ToUpper().Contains("embaixador") || ExtraData.ToUpper().Contains("AJUDANTE") || ExtraData.ToUpper().Contains("EMBAIXADOR") || ExtraData.ToUpper().Contains("VIP") || ExtraData.ToUpper().Contains("vip") || ExtraData.ToUpper().Contains("PROG") || ExtraData.ToUpper().Contains("prog")) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper("O que você está tentando? Não coloque uma tag administrativa ou você será punido", 34); return; } if (ExtraData == "off" || ExtraData == "") { Session.GetHabbo()._NamePrefix = ""; Session.SendNotification("você tem prefixos de nomes eficientes para o seu " + BiosEmuThiago.HotelName + "'s"); } ExtraData = BiosEmuThiago.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(ExtraData, out string character) ? "" : ExtraData; if (string.IsNullOrEmpty(ExtraData)) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper(character.ToUpper() + " Não é uma palavra apropriada!", 34); return; } if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name` = '" + ExtraData + "' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.GetHabbo()._NamePrefix = ExtraData; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.prefixcolor) { if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `prefix_name_color` = @prefixn WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); dbClient.AddParameter("prefixn", "#" + Item.Name); dbClient.RunQuery(); } Session.GetHabbo()._NamePrefixColor = "#" + Item.Name; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.CLUB_VIP || baseItem.InteractionType == InteractionType.CLUB_VIP2) { // int Months = 0; switch (baseItem.InteractionType) { case InteractionType.CLUB_VIP: /// Months = 1; break; case InteractionType.CLUB_VIP2: // Months = 3; break; } if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Session.GetHabbo().GetClubManager().AddOrExtendSubscription("club_vip", 1 * 24 * 3600, Session); Session.GetHabbo().GetBadgeComponent().GiveBadge("DVIP", true, Session); BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_VipClub", 1); Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); if (Session.GetHabbo().Rank > 2) { Session.SendWhisper("Ops! Deu ruim ai!"); return; } else if (Session.GetHabbo().Rank < 2) { using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `rank` = '2' WHERE `id` = '" + Session.GetHabbo().Id + "'"); dbClient.runFastQuery("UPDATE `users` SET `rank_vip` = '1' WHERE `id` = '" + Session.GetHabbo().Id + "'"); Session.GetHabbo().Rank = 2; Session.GetHabbo().VIPRank = 1; } } return; } if (Amount < 1 || Amount > 100 || !Item.HaveOffer) { Amount = 1; } int AmountPurchase = Item.Amount > 1 ? Item.Amount : Amount; int TotalCreditsCost = Amount > 1 ? ((Item.CostCredits * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostCredits)) : Item.CostCredits; int TotalPixelCost = Amount > 1 ? ((Item.CostPixels * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostPixels)) : Item.CostPixels; int TotalDiamondCost = Amount > 1 ? ((Item.CostDiamonds * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDiamonds)) : Item.CostDiamonds; int TotalGotwCost = Amount > 1 ? ((Item.CostGotw * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostGotw)) : Item.CostGotw; if (Session.GetHabbo().Credits < TotalCreditsCost || Session.GetHabbo().Duckets < TotalPixelCost || Session.GetHabbo().Diamonds < TotalDiamondCost || Session.GetHabbo().GOTWPoints < TotalGotwCost) { return; } int LimitedEditionSells = 0; int LimitedEditionStack = 0; #region PREDESIGNED_ROOM if (Item.PredesignedId > 0 && BiosEmuThiago.GetGame().GetCatalog().GetPredesignedRooms().predesignedRoom.ContainsKey((uint)Item.PredesignedId)) { if (Item.CostCredits > Session.GetHabbo().Credits) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } #region SELECT ROOM AND CREATE NEW var predesigned = BiosEmuThiago.GetGame().GetCatalog().GetPredesignedRooms().predesignedRoom[(uint)Item.PredesignedId]; var decoration = predesigned.RoomDecoration; var createRoom = BiosEmuThiago.GetGame().GetRoomManager().CreateRoom(Session, "Pack: " + Item.Name + " !", "Esse é um pack de quarto Comprado na loja do hotel!", predesigned.RoomModel, 1, 25, 1); createRoom.FloorThickness = int.Parse(decoration[0]); createRoom.WallThickness = int.Parse(decoration[1]); createRoom.Model.WallHeight = int.Parse(decoration[2]); createRoom.Hidewall = ((decoration[3] == "True") ? 1 : 0); createRoom.Wallpaper = decoration[4]; createRoom.Landscape = decoration[5]; createRoom.Floor = decoration[6]; var newRoom = BiosEmuThiago.GetGame().GetRoomManager().LoadRoom(createRoom.Id); #endregion #region CREATE FLOOR ITEMS if (predesigned.FloorItems != null) { foreach (var floorItems in predesigned.FloorItemData) { using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) dbClient.RunQuery("INSERT INTO items VALUES (null, " + Session.GetHabbo().Id + ", " + newRoom.RoomId + ", " + floorItems.BaseItem + ", '" + floorItems.ExtraData + "', " + floorItems.X + ", " + floorItems.Y + ", " + TextHandling.GetString(floorItems.Z) + ", " + floorItems.Rot + ", '', 0, 0);"); } } #endregion #region CREATE WALL ITEMS if (predesigned.WallItems != null) { foreach (var wallItems in predesigned.WallItemData) { using (var dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) dbClient.RunQuery("INSERT INTO items VALUES (null, " + Session.GetHabbo().Id + ", " + newRoom.RoomId + ", " + wallItems.BaseItem + ", '" + wallItems.ExtraData + "', 0, 0, 0, 0, '" + wallItems.WallCoord + "', 0, 0);"); } } #endregion #region VERIFY IF CONTAINS BADGE AND GIVE if (Item.Badge != string.Empty) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Badge, true, Session); } #endregion #region GENERATE ROOM AND SEND PACKET Session.SendMessage(new PurchaseOKComposer()); Session.GetHabbo().GetInventoryComponent().UpdateItems(false); BiosEmuThiago.GetGame().GetRoomManager().LoadRoom(newRoom.Id).GetRoomItemHandler().LoadFurniture(); var newFloorItems = newRoom.GetRoomItemHandler().GetFloor; foreach (var roomItem in newFloorItems) { newRoom.GetRoomItemHandler().SetFloorItem(roomItem, roomItem.GetX, roomItem.GetY, roomItem.GetZ); } var newWallItems = newRoom.GetRoomItemHandler().GetWall; foreach (var roomItem in newWallItems) { newRoom.GetRoomItemHandler().SetWallItem(Session, roomItem); } Session.SendMessage(new FlatCreatedComposer(newRoom.Id, newRoom.Name)); #endregion return; } #endregion #region Create the extradata switch (Item.Data.InteractionType) { case InteractionType.NONE: ExtraData = ""; break; case InteractionType.GUILD_FORUM: Group Gp; GroupForum Gf; int GpId; if (!int.TryParse(ExtraData, out GpId)) { Session.SendNotification("Ops! Ocorreu algum erro ao obter o ID do grupo"); Session.SendMessage(new PurchaseOKComposer()); return; } if (!BiosEmuThiago.GetGame().GetGroupManager().TryGetGroup(GpId, out Gp)) { Session.SendNotification("Ops! Esse ID não existe!"); Session.SendMessage(new PurchaseOKComposer()); return; } if (Gp.CreatorId != Session.GetHabbo().Id) { Session.SendNotification("Ops! Você não é o proprietário do grupo.\n\nFórum deve ser criado pelo proprietário do grupo..."); Session.SendMessage(new PurchaseOKComposer()); return; } Gf = BiosEmuThiago.GetGame().GetGroupForumManager().CreateGroupForum(Gp); Session.SendMessage(new RoomNotificationComposer("forums.delivered", new Dictionary <string, string> { { "groupId", Gp.Id.ToString() }, { "groupName", Gp.Name } })); break; case InteractionType.GUILD_FORUM_CHAT: Group thegroup; Group Group = null; if (!BiosEmuThiago.GetGame().GetGroupManager().TryGetGroup(Convert.ToInt32(ExtraData), out thegroup)) { return; } if (!(BiosEmuThiago.GetGame().GetGroupManager().GetGroupsForUser(Session.GetHabbo().Id).Contains(thegroup))) { return; } int groupID = Convert.ToInt32(ExtraData); if (thegroup.CreatorId != Session.GetHabbo().Id) { Session.SendNotification("Ops! Você não é o dono do grupo para pode compra o chat de grupo!"); Session.SendMessage(new PurchaseOKComposer()); return; } using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE groups SET has_chat = '1' WHERE id = @id"); dbClient.AddParameter("id", groupID); dbClient.RunQuery(); } BiosEmuThiago.GetGame().GetClientManager().GetClientByUserID(Session.GetHabbo().Id).SendMessage(new FriendListUpdateComposer(Group, 1)); Session.SendNotification("Chat de grupo criado com exito! Bom proveitos a todos os membros."); Session.SendMessage(new PurchaseOKComposer()); break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: case InteractionType.HCGATE: case InteractionType.VIPGATE: break; case InteractionType.PINATA: case InteractionType.PINATATRIGGERED: case InteractionType.MAGICEGG: case InteractionType.MAGICCHEST: ExtraData = "0"; break; #region Pet handling case InteractionType.PET: try { string[] Bits = ExtraData.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; } BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); } catch (Exception e) { ExceptionLogger.LogException(e); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(ExtraData)) { Number = 0; } else { Number = Double.Parse(ExtraData, BiosEmuThiago.CultureInfo); } } catch (Exception e) { ExceptionLogger.LogException(e); } ExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ExtraData; break; case InteractionType.MANNEQUIN: ExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin"; break; case InteractionType.FOOTBALL_GATE: ExtraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62"; break; case InteractionType.vikingtent: ExtraData = "0"; break; case InteractionType.BADGE_DISPLAY: if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData)) { Session.SendMessage(new BroadcastMessageAlertComposer("Parece que você não é dono desse Emblema!")); return; } ExtraData = ExtraData + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Data.ItemName)) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } break; } default: ExtraData = ""; break; } #endregion if (Item.IsLimited) { if (Item.LimitedEditionStack <= Item.LimitedEditionSells) { Session.SendNotification("Este item está esgotado!\n\n" + "Por favor, note que você não recebeu outro item (Você também não foi cobrado por isso!)"); Session.SendMessage(new CatalogUpdatedComposer()); Session.SendMessage(new PurchaseOKComposer()); return; } Item.LimitedEditionSells++; using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", Item.LimitedEditionSells); dbClient.AddParameter("itemId", Item.Id); dbClient.RunQuery(); LimitedEditionSells = Item.LimitedEditionSells; LimitedEditionStack = Item.LimitedEditionStack; } if (Session.GetHabbo().Rank == 1) { BiosEmuThiago.GetGame().GetClientManager().SendMessage(new RoomNotificationComposer("icons/" + Item.Data.ItemName + "_icon", 3, "O usuário " + Session.GetHabbo().Username + " comprou o raro LTD: " + Item.Name + " Slot: " + Item.LimitedEditionSells + "/" + Item.LimitedEditionStack, "!")); } } if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= TotalCreditsCost; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostPixels > 0) { Session.GetHabbo().Duckets -= TotalPixelCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= TotalDiamondCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= TotalGotwCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Item NewItem = null; switch (Item.Data.Type.ToString().ToLower()) { default: List <Item> GeneratedGenericItems = new List <Item>(); switch (Item.Data.InteractionType) { default: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, 0, LimitedEditionSells, LimitedEditionStack); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.GUILD_GATE: case InteractionType.GUILD_ITEM: case InteractionType.GUILD_FORUM: int groupId = 0; int.TryParse(ExtraData, out groupId); if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase, groupId); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, groupId); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.MUSIC_DISC: string flags = Convert.ToString(Item.ExtradataInt); if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), flags, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_MusicCollector", 1); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), flags, flags); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); BiosEmuThiago.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_MusicCollector", 1); } } break; case InteractionType.ARROW: case InteractionType.TELEPORT: for (int i = 0; i < AmountPurchase; i++) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(Item.Data, Session.GetHabbo()); if (TeleItems != null) { GeneratedGenericItems.AddRange(TeleItems); } } break; case InteractionType.MOODLIGHT: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateMoodlightData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateMoodlightData(NewItem); } } } break; case InteractionType.TONER: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateTonerData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateTonerData(NewItem); } } } break; case InteractionType.DEAL: { //Fetch the deal where the ID is this items ID. var DealItems = (from d in Page.Deals.Values.ToList() where d.Id == Item.Id select d); //This bit, iterating ONE item? How can I make this simpler foreach (CatalogDeal DealItem in DealItems) { //Here I loop the DealItems ItemDataList. foreach (CatalogItem CatalogItem in DealItem.ItemDataList.ToList()) { List <Item> Items = ItemFactory.CreateMultipleItems(CatalogItem.Data, Session.GetHabbo(), "", AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } } break; } } foreach (Item PurchasedItem in GeneratedGenericItems) { if (Session.GetHabbo().GetInventoryComponent().TryAddItem(PurchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); Session.SendMessage(new FurniListNotificationComposer(PurchasedItem.Id, 1)); } } break; case "e": AvatarEffect Effect = null; if (Session.GetHabbo().Effects().HasEffect(Item.Data.SpriteId)) { Effect = Session.GetHabbo().Effects().GetEffectNullable(Item.Data.SpriteId); if (Effect != null) { Effect.AddToQuantity(); } } else { Effect = AvatarEffectFactory.CreateNullable(Session.GetHabbo(), Item.Data.SpriteId, 3600); } if (Effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { Session.SendMessage(new AvatarEffectAddedComposer(Item.Data.SpriteId, 3600)); Session.GetHabbo().Effects().ApplyEffect(Item.Data.SpriteId); Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "Você compro o efeito " + Item.Data.SpriteId + " na loja, lembre-se você ganho o efeito no seu avatar, mais so ira para o seu inventário apos você relogar")); } break; case "r": Bot Bot = BotUtility.CreateBot(Item.Data, Session.GetHabbo().Id); if (Bot != null) { Session.GetHabbo().GetInventoryComponent().TryAddBot(Bot); Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); Session.SendMessage(new FurniListNotificationComposer(Bot.Id, 5)); } else { Session.SendNotification("Houve um erro ao comprar isso!"); } break; case "b": { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Data.ItemName, true, Session); Session.SendMessage(new FurniListNotificationComposer(0, 4)); break; } case "p": { string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = PetUtility.CreatePet(Session.GetHabbo().Id, PetData[0], Item.Data.BehaviourData, PetData[1], PetData[2]); if (GeneratedPet != null) { Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet); Session.SendMessage(new FurniListNotificationComposer(GeneratedPet.PetId, 3)); Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); if (BiosEmuThiago.GetGame().GetItemManager().GetItem(320, out ItemData PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), "", ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendMessage(new FurniListNotificationComposer(Food.Id, 1)); } } } break; } } if (Item.Badge != string.Empty) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Badge, true, Session); } Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); }
public void Parse(GameClient session, ClientPacket packet) { if (PlusEnvironment.GetSettingsManager().TryGetValue("catalog.enabled") != "1") { session.SendNotification("The hotel managers have disabled the catalogue"); return; } int pageId = packet.PopInt(); int itemId = packet.PopInt(); string extraData = packet.PopString(); int amount = packet.PopInt(); if (!PlusEnvironment.GetGame().GetCatalog().TryGetPage(pageId, out CatalogPage page)) { return; } if (!page.Enabled || !page.Visible || page.MinimumRank > session.GetHabbo().Rank || (page.MinimumVIP > session.GetHabbo().VIPRank&& session.GetHabbo().Rank == 1)) { return; } if (!page.Items.TryGetValue(itemId, out CatalogItem item)) { if (page.ItemOffers.ContainsKey(itemId)) { item = page.ItemOffers[itemId]; if (item == null) { return; } } else { return; } } if (amount < 1 || amount > 100 || !item.HaveOffer) { amount = 1; } int amountPurchase = item.Amount > 1 ? item.Amount : amount; int totalCreditsCost = amount > 1 ? ((item.CostCredits * amount) - ((int)Math.Floor((double)amount / 6) * item.CostCredits)) : item.CostCredits; int totalPixelCost = amount > 1 ? ((item.CostPixels * amount) - ((int)Math.Floor((double)amount / 6) * item.CostPixels)) : item.CostPixels; int totalDiamondCost = amount > 1 ? ((item.CostDiamonds * amount) - ((int)Math.Floor((double)amount / 6) * item.CostDiamonds)) : item.CostDiamonds; if (session.GetHabbo().Credits < totalCreditsCost || session.GetHabbo().Duckets < totalPixelCost || session.GetHabbo().Diamonds < totalDiamondCost) { return; } int limitedEditionSells = 0; int limitedEditionStack = 0; #region Create the extradata switch (item.Data.InteractionType) { case InteractionType.NONE: extraData = ""; break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: break; #region Pet handling case InteractionType.PET: try { string[] bits = extraData.Split('\n'); string petName = bits[0]; string race = bits[1]; string color = bits[2]; if (!PetUtility.CheckPetName(petName)) { return; } if (race.Length > 2) { return; } if (color.Length != 6) { return; } PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_PetLover", 1); } catch (Exception e) { ExceptionLogger.LogException(e); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: double number = 0; try { number = string.IsNullOrEmpty(extraData) ? 0 : double.Parse(extraData, PlusEnvironment.CultureInfo); } catch (Exception e) { ExceptionLogger.LogException(e); } extraData = number.ToString(CultureInfo.CurrentCulture).Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: extraData = "FFFF33"; break; case InteractionType.MOODLIGHT: extraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: extraData = session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + extraData; break; case InteractionType.MANNEQUIN: extraData = "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(extraData)) { session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge.")); return; } extraData = extraData + Convert.ToChar(9) + session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (session.GetHabbo().GetBadgeComponent().HasBadge(item.Data.ItemName)) { session.SendPacket(new PurchaseErrorComposer(1)); return; } break; } default: extraData = ""; break; } #endregion if (item.IsLimited) { if (item.LimitedEditionStack <= item.LimitedEditionSells) { session.SendNotification("This item has sold out!\n\n" + "Please note, you have not recieved another item (You have also not been charged for it!)"); session.SendPacket(new CatalogUpdatedComposer()); session.SendPacket(new PurchaseOKComposer()); return; } item.LimitedEditionSells++; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", item.LimitedEditionSells); dbClient.AddParameter("itemId", item.Id); dbClient.RunQuery(); limitedEditionSells = item.LimitedEditionSells; limitedEditionStack = item.LimitedEditionStack; } } if (item.CostCredits > 0) { session.GetHabbo().Credits -= totalCreditsCost; session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits)); } if (item.CostPixels > 0) { session.GetHabbo().Duckets -= totalPixelCost; session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, session.GetHabbo().Duckets));//Love you, Tom. } if (item.CostDiamonds > 0) { session.GetHabbo().Diamonds -= totalDiamondCost; session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Diamonds, 0, 5)); } switch (item.Data.Type.ToString().ToLower()) { default: List <Item> generatedGenericItems = new List <Item>(); Item newItem; switch (item.Data.InteractionType) { default: if (amountPurchase > 1) { List <Item> items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, extraData, 0, limitedEditionSells, limitedEditionStack); if (newItem != null) { generatedGenericItems.Add(newItem); } } break; case InteractionType.GUILD_GATE: case InteractionType.GUILD_ITEM: case InteractionType.GUILD_FORUM: if (amountPurchase > 1) { List <Item> items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase, Convert.ToInt32(extraData)); if (items != null) { generatedGenericItems.AddRange(items); } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, extraData, Convert.ToInt32(extraData)); if (newItem != null) { generatedGenericItems.Add(newItem); } } break; case InteractionType.ARROW: case InteractionType.TELEPORT: for (int i = 0; i < amountPurchase; i++) { List <Item> teleItems = ItemFactory.CreateTeleporterItems(item.Data, session.GetHabbo()); if (teleItems != null) { generatedGenericItems.AddRange(teleItems); } } break; case InteractionType.MOODLIGHT: { if (amountPurchase > 1) { List <Item> items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); foreach (Item I in items) { ItemFactory.CreateMoodlightData(I); } } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, extraData); if (newItem != null) { generatedGenericItems.Add(newItem); ItemFactory.CreateMoodlightData(newItem); } } } break; case InteractionType.TONER: { if (amountPurchase > 1) { List <Item> items = ItemFactory.CreateMultipleItems(item.Data, session.GetHabbo(), extraData, amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); foreach (Item I in items) { ItemFactory.CreateTonerData(I); } } } else { newItem = ItemFactory.CreateSingleItemNullable(item.Data, session.GetHabbo(), extraData, extraData); if (newItem != null) { generatedGenericItems.Add(newItem); ItemFactory.CreateTonerData(newItem); } } } break; case InteractionType.DEAL: { if (PlusEnvironment.GetGame().GetCatalog().TryGetDeal(item.Data.BehaviourData, out CatalogDeal deal)) { foreach (CatalogItem catalogItem in deal.ItemDataList.ToList()) { List <Item> items = ItemFactory.CreateMultipleItems(catalogItem.Data, session.GetHabbo(), "", amountPurchase); if (items != null) { generatedGenericItems.AddRange(items); } } } break; } } foreach (Item purchasedItem in generatedGenericItems) { if (session.GetHabbo().GetInventoryComponent().TryAddItem(purchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); session.SendPacket(new FurniListNotificationComposer(purchasedItem.Id, 1)); } } break; case "e": AvatarEffect effect; if (session.GetHabbo().Effects().HasEffect(item.Data.SpriteId)) { effect = session.GetHabbo().Effects().GetEffectNullable(item.Data.SpriteId); if (effect != null) { effect.AddToQuantity(); } } else { effect = AvatarEffectFactory.CreateNullable(session.GetHabbo(), item.Data.SpriteId, 3600); } if (effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { session.SendPacket(new AvatarEffectAddedComposer(item.Data.SpriteId, 3600)); } break; case "r": Bot bot = BotUtility.CreateBot(item.Data, session.GetHabbo().Id); if (bot != null) { session.GetHabbo().GetInventoryComponent().TryAddBot(bot); session.SendPacket(new BotInventoryComposer(session.GetHabbo().GetInventoryComponent().GetBots())); session.SendPacket(new FurniListNotificationComposer(bot.Id, 5)); } else { session.SendNotification("Oops! There was an error whilst purchasing this bot. It seems that there is no bot data for the bot!"); } break; case "b": { session.GetHabbo().GetBadgeComponent().GiveBadge(item.Data.ItemName, true, session); session.SendPacket(new FurniListNotificationComposer(0, 4)); break; } case "p": { string[] petData = extraData.Split('\n'); Pet generatedPet = PetUtility.CreatePet(session.GetHabbo().Id, petData[0], item.Data.BehaviourData, petData[1], petData[2]); if (generatedPet != null) { session.GetHabbo().GetInventoryComponent().TryAddPet(generatedPet); session.SendPacket(new FurniListNotificationComposer(generatedPet.PetId, 3)); session.SendPacket(new PetInventoryComposer(session.GetHabbo().GetInventoryComponent().GetPets())); if (PlusEnvironment.GetGame().GetItemManager().GetItem(320, out ItemData petFood)) { Item food = ItemFactory.CreateSingleItemNullable(petFood, session.GetHabbo(), "", ""); if (food != null) { session.GetHabbo().GetInventoryComponent().TryAddItem(food); session.SendPacket(new FurniListNotificationComposer(food.Id, 1)); } } } break; } } if (!string.IsNullOrEmpty(item.Badge) && PlusEnvironment.GetGame().GetBadgeManager().TryGetBadge(item.Badge, out BadgeDefinition badge) && (string.IsNullOrEmpty(badge.RequiredRight) || session.GetHabbo().GetPermissions().HasRight(badge.RequiredRight))) { session.GetHabbo().GetBadgeComponent().GiveBadge(badge.Code, true, session); } session.SendPacket(new PurchaseOKComposer(item, item.Data)); session.SendPacket(new FurniListUpdateComposer()); }
public void Parse(GameClient Session, ClientPacket Packet) { ICollection <Item> FloorItems = Session.GetHabbo().GetInventoryComponent().GetFloorItems(); ICollection <Item> WallItems = Session.GetHabbo().GetInventoryComponent().GetWallItems(); if (CloudServer.GetGame().GetSettingsManager().TryGetValue("catalog.enabled") != "1") { Session.SendNotification("Os gerentes do Hotel desabilitaram o catalogo!"); return; } int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string ExtraData = Packet.PopString(); int Amount = Packet.PopInt(); if (!CloudServer.GetGame().GetCatalog().TryGetPage(PageId, out CatalogPage Page)) { return; } if (!Page.Enabled || !Page.Visible || Page.MinimumRank > Session.GetHabbo().Rank || (Page.MinimumVIP > Session.GetHabbo().VIPRank&& Session.GetHabbo().Rank == 1)) { return; } if (!Page.Items.TryGetValue(ItemId, out CatalogItem Item)) { if (Page.ItemOffers.ContainsKey(ItemId)) { Item = Page.ItemOffers[ItemId]; if (Item == null) { return; } } else { return; } } ItemData baseItem = Item.GetBaseItem(Item.ItemId); if (baseItem != null) { if (baseItem.InteractionType == InteractionType.club_1_month || baseItem.InteractionType == InteractionType.club_3_month || baseItem.InteractionType == InteractionType.club_6_month) { int Months = 0; switch (baseItem.InteractionType) { case InteractionType.club_1_month: Months = 1; break; case InteractionType.club_3_month: Months = 3; break; case InteractionType.club_6_month: Months = 6; break; } int num = num = 31 * Months; if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Session.GetHabbo().GetClubManager().AddOrExtendSubscription("habbo_vip", num * 24 * 3600, Session); Session.GetHabbo().GetBadgeComponent().GiveBadge("HC1", true, Session); Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } } if (baseItem.InteractionType == InteractionType.namecolor) { if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `name_color` = '#" + Item.Name + "' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.GetHabbo().chatHTMLColour = "#" + Item.Name; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.prefixname) { if (ExtraData.Length > 6 || ExtraData.Length == 0 || ExtraData.Length < 0) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper("Você deve digitar um código de 1 a 6 caracteres para adquirir.", 34); return; } if (Session.GetHabbo().Rank < 3) { if (ExtraData.ToUpper().Contains("ADM") || ExtraData.ToUpper().Contains("ADMIN") || ExtraData.ToUpper().Contains("GER") || ExtraData.ToUpper().Contains("DONO") || ExtraData.ToUpper().Contains("RANK") || ExtraData.ToUpper().Contains("MNG") || ExtraData.ToUpper().Contains("MOD") || ExtraData.ToUpper().Contains("STAFF") || ExtraData.ToUpper().Contains("ALFA") || ExtraData.ToUpper().Contains("ALPHA") || ExtraData.ToUpper().Contains("HELPER") || ExtraData.ToUpper().Contains("GM") || ExtraData.ToUpper().Contains("CEO") || ExtraData.ToUpper().Contains("ROOKIE") || ExtraData.ToUpper().Contains("M0D") || ExtraData.ToUpper().Contains("DEV") || ExtraData.ToUpper().Contains("OWNR") || ExtraData.ToUpper().Contains("FUNDADOR")) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper("O que você está tentando? Não coloque um prefixo administrativa ou você será punido", 34); return; } } if (ExtraData == "off" || ExtraData == "") { Session.GetHabbo()._NamePrefix = ""; Session.SendNotification("você tem prefixos de nomes eficientes para o seu " + CloudServer.HotelName + "'s"); } ExtraData = CloudServer.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(ExtraData, out string character) ? "" : ExtraData; if (string.IsNullOrEmpty(ExtraData)) { Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendWhisper(character.ToUpper() + "Não é uma palavra apropriada, para que você não possa colocar este prefixo.", 34); return; } if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `prefix_name` = '" + ExtraData + "' WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); } Session.GetHabbo()._NamePrefix = ExtraData; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.prefixcolor) { if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `users` SET `prefix_name_color` = @prefixn WHERE `id` = '" + Session.GetHabbo().Id + "' LIMIT 1"); dbClient.AddParameter("prefixn", "#" + Item.Name); dbClient.RunQuery(); } Session.GetHabbo()._NamePrefixColor = "#" + Item.Name; Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); return; } if (baseItem.InteractionType == InteractionType.CLUB_VIP || baseItem.InteractionType == InteractionType.CLUB_VIP2) { // int Months = 0; switch (baseItem.InteractionType) { case InteractionType.CLUB_VIP: /// Months = 1; break; case InteractionType.CLUB_VIP2: // Months = 3; break; } if (Item.CostCredits > Session.GetHabbo().Credits || Item.CostPixels > Session.GetHabbo().Duckets || Item.CostDiamonds > Session.GetHabbo().Diamonds || Item.CostGotw > Session.GetHabbo().GOTWPoints) { return; } 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));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= Item.CostDiamonds; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= Item.CostGotw; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Session.GetHabbo().GetClubManager().AddOrExtendSubscription("club_vip", 1 * 24 * 3600, Session); Session.GetHabbo().GetBadgeComponent().GiveBadge("DVIP", true, Session); CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_VipClub", 1); Session.SendMessage(new ScrSendUserInfoComposer(Session.GetHabbo())); Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); if (Session.GetHabbo().Rank > 2) { Session.SendWhisper("Ops! Deu ruim ai!"); return; } else if (Session.GetHabbo().Rank < 2) { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.runFastQuery("UPDATE `users` SET `rank` = '2' WHERE `id` = '" + Session.GetHabbo().Id + "'"); dbClient.runFastQuery("UPDATE `users` SET `rank_vip` = '1' WHERE `id` = '" + Session.GetHabbo().Id + "'"); Session.GetHabbo().Rank = 2; Session.GetHabbo().VIPRank = 1; } } return; } if (Amount < 1 || Amount > 100 || !Item.HaveOffer) { Amount = 1; } int AmountPurchase = Item.Amount > 1 ? Item.Amount : Amount; int TotalCreditsCost = Amount > 1 ? ((Item.CostCredits * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostCredits)) : Item.CostCredits; int TotalPixelCost = Amount > 1 ? ((Item.CostPixels * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostPixels)) : Item.CostPixels; int TotalDiamondCost = Amount > 1 ? ((Item.CostDiamonds * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDiamonds)) : Item.CostDiamonds; int TotalGotwCost = Amount > 1 ? ((Item.CostGotw * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostGotw)) : Item.CostGotw; if (Session.GetHabbo().Credits < TotalCreditsCost || Session.GetHabbo().Duckets < TotalPixelCost || Session.GetHabbo().Diamonds < TotalDiamondCost || Session.GetHabbo().GOTWPoints < TotalGotwCost) { return; } int LimitedEditionSells = 0; int LimitedEditionStack = 0; #region PREDESIGNED_ROOM if (Item.PredesignedId > 0 && CloudServer.GetGame().GetCatalog().GetPredesignedRooms().predesignedRoom.ContainsKey((uint)Item.PredesignedId)) { #region SELECT ROOM AND CREATE NEW var predesigned = CloudServer.GetGame().GetCatalog().GetPredesignedRooms().predesignedRoom[(uint)Item.PredesignedId]; var decoration = predesigned.RoomDecoration; var createRoom = CloudServer.GetGame().GetRoomManager().CreateRoom(Session, "Sala de " + Session.GetHabbo().Username, "Una Sala pre-decorada :)", predesigned.RoomModel, 1, 25, 1); createRoom.FloorThickness = int.Parse(decoration[0]); createRoom.WallThickness = int.Parse(decoration[1]); createRoom.Model.WallHeight = int.Parse(decoration[2]); createRoom.Hidewall = ((decoration[3] == "True") ? 1 : 0); createRoom.Wallpaper = decoration[4]; createRoom.Landscape = decoration[5]; createRoom.Floor = decoration[6]; var newRoom = CloudServer.GetGame().GetRoomManager().LoadRoom(createRoom.Id); #endregion #region CREATE FLOOR ITEMS if (predesigned.FloorItems != null) { foreach (var floorItems in predesigned.FloorItemData) { using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) dbClient.runFastQuery("INSERT INTO items VALUES (null, " + Session.GetHabbo().Id + ", " + newRoom.RoomId + ", " + floorItems.BaseItem + ", '" + floorItems.ExtraData + "', " + floorItems.X + ", " + floorItems.Y + ", " + TextHandling.GetString(floorItems.Z) + ", " + floorItems.Rot + ", '', 0, 0);"); } } #endregion #region CREATE WALL ITEMS if (predesigned.WallItems != null) { foreach (var wallItems in predesigned.WallItemData) { using (var dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) dbClient.runFastQuery("INSERT INTO items VALUES (null, " + Session.GetHabbo().Id + ", " + newRoom.RoomId + ", " + wallItems.BaseItem + ", '" + wallItems.ExtraData + "', 0, 0, 0, 0, '" + wallItems.WallCoord + "', 0, 0);"); } } #endregion #region VERIFY IF CONTAINS BADGE AND GIVE if (Item.Badge != string.Empty) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Badge, true, Session); } #endregion #region GENERATE ROOM AND SEND PACKET Session.SendMessage(new PurchaseOKComposer()); Session.GetHabbo().GetInventoryComponent().UpdateItems(false); CloudServer.GetGame().GetRoomManager().LoadRoom(newRoom.Id).GetRoomItemHandler().LoadFurniture(); var newFloorItems = newRoom.GetRoomItemHandler().GetFloor; foreach (var roomItem in newFloorItems) { newRoom.GetRoomItemHandler().SetFloorItem(roomItem, roomItem.GetX, roomItem.GetY, roomItem.GetZ); } var newWallItems = newRoom.GetRoomItemHandler().GetWall; foreach (var roomItem in newWallItems) { newRoom.GetRoomItemHandler().SetWallItem(Session, roomItem); } Session.SendMessage(new FlatCreatedComposer(newRoom.Id, newRoom.Name)); #endregion return; } #endregion #region Create the extradata switch (Item.Data.InteractionType) { case InteractionType.NONE: ExtraData = ""; break; case InteractionType.GUILD_FORUM: Group Gp; GroupForum Gf; int GpId; if (!int.TryParse(ExtraData, out GpId)) { Session.SendNotification("Ops! Ocorreu algum erro ao obter o ID do grupo"); Session.SendMessage(new PurchaseOKComposer()); return; } if (!CloudServer.GetGame().GetGroupManager().TryGetGroup(GpId, out Gp)) { Session.SendNotification("Ops! Esse ID não existe!"); Session.SendMessage(new PurchaseOKComposer()); return; } if (Gp.CreatorId != Session.GetHabbo().Id) { Session.SendNotification("Ops! Você não é o proprietário do grupo para que você criar o fórum.\n\nPrimero o fórum deve ser criado pelo grupo proprietário..."); Session.SendMessage(new PurchaseOKComposer()); return; } Gf = CloudServer.GetGame().GetGroupForumManager().CreateGroupForum(Gp); Session.SendMessage(new RoomNotificationComposer("forums.delivered", new Dictionary <string, string> { { "groupId", Gp.Id.ToString() }, { "groupName", Gp.Name } })); break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: case InteractionType.HCGATE: case InteractionType.VIPGATE: break; case InteractionType.PINATA: case InteractionType.PINATATRIGGERED: case InteractionType.MAGICEGG: case InteractionType.MAGICCHEST: ExtraData = "0"; break; #region Pet handling case InteractionType.PET: try { string[] Bits = ExtraData.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; } CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); } catch (Exception e) { ExceptionLogger.LogException(e); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(ExtraData)) { Number = 0; } else { Number = Double.Parse(ExtraData, CloudServer.CultureInfo); } } catch (Exception e) { ExceptionLogger.LogException(e); } ExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ExtraData; break; case InteractionType.MANNEQUIN: ExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin"; break; case InteractionType.FOOTBALL_GATE: ExtraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62"; break; case InteractionType.vikingtent: ExtraData = "0"; break; case InteractionType.BADGE_DISPLAY: if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData)) { Session.SendMessage(new BroadcastMessageAlertComposer("Parece que você não é dono desse Emblema!")); return; } ExtraData = ExtraData + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Data.ItemName)) { Session.SendMessage(new PurchaseErrorComposer(1)); return; } break; } default: ExtraData = ""; break; } #endregion if (Item.IsLimited) { if (Item.LimitedEditionStack <= Item.LimitedEditionSells) { Session.SendNotification("Essa noticia expirou!\n\n" + "Por favor, note que você não tenha recebido um outro artigo (você também não foi cobrado por ele!)"); Session.SendMessage(new CatalogUpdatedComposer()); Session.SendMessage(new PurchaseOKComposer()); return; } Item.LimitedEditionSells++; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", Item.LimitedEditionSells); dbClient.AddParameter("itemId", Item.Id); dbClient.RunQuery(); LimitedEditionSells = Item.LimitedEditionSells; LimitedEditionStack = Item.LimitedEditionStack; } } if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= TotalCreditsCost; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostPixels > 0) { Session.GetHabbo().Duckets -= TotalPixelCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= TotalDiamondCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } if (Item.CostGotw > 0) { Session.GetHabbo().GOTWPoints -= TotalGotwCost; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, 0, 103)); } Item NewItem = null; switch (Item.Data.Type.ToString().ToLower()) { default: List <Item> GeneratedGenericItems = new List <Item>(); switch (Item.Data.InteractionType) { default: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, 0, LimitedEditionSells, LimitedEditionStack); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.GUILD_GATE: case InteractionType.GUILD_ITEM: case InteractionType.GUILD_FORUM: int groupId = 0; int.TryParse(ExtraData, out groupId); if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase, groupId); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, groupId); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.MUSIC_DISC: string flags = Convert.ToString(Item.ExtradataInt); if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), flags, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), flags, flags); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.ARROW: case InteractionType.TELEPORT: for (int i = 0; i < AmountPurchase; i++) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(Item.Data, Session.GetHabbo()); if (TeleItems != null) { GeneratedGenericItems.AddRange(TeleItems); } } break; case InteractionType.MOODLIGHT: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateMoodlightData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateMoodlightData(NewItem); } } } break; case InteractionType.TONER: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateTonerData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateTonerData(NewItem); } } } break; case InteractionType.DEAL: { //Fetch the deal where the ID is this items ID. var DealItems = (from d in Page.Deals.Values.ToList() where d.Id == Item.Id select d); //This bit, iterating ONE item? How can I make this simpler foreach (CatalogDeal DealItem in DealItems) { //Here I loop the DealItems ItemDataList. foreach (CatalogItem CatalogItem in DealItem.ItemDataList.ToList()) { List <Item> Items = ItemFactory.CreateMultipleItems(CatalogItem.Data, Session.GetHabbo(), "", AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } } break; } } foreach (Item PurchasedItem in GeneratedGenericItems) { if (Session.GetHabbo().GetInventoryComponent().TryAddItem(PurchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); Session.SendMessage(new FurniListNotificationComposer(PurchasedItem.Id, 1)); } } break; case "e": AvatarEffect Effect = null; if (Session.GetHabbo().Effects().HasEffect(Item.Data.SpriteId)) { Effect = Session.GetHabbo().Effects().GetEffectNullable(Item.Data.SpriteId); if (Effect != null) { Effect.AddToQuantity(); } } else { Effect = AvatarEffectFactory.CreateNullable(Session.GetHabbo(), Item.Data.SpriteId, 3600); } if (Effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { Session.SendMessage(new AvatarEffectAddedComposer(Item.Data.SpriteId, 3600)); } break; case "r": Bot Bot = BotUtility.CreateBot(Item.Data, Session.GetHabbo().Id); if (Bot != null) { Session.GetHabbo().GetInventoryComponent().TryAddBot(Bot); Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); Session.SendMessage(new FurniListNotificationComposer(Bot.Id, 5)); } else { Session.SendNotification("Houve um erro ao comprar isso!"); } break; case "b": { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Data.ItemName, true, Session); Session.SendMessage(new FurniListNotificationComposer(0, 4)); break; } case "p": { string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = PetUtility.CreatePet(Session.GetHabbo().Id, PetData[0], Item.Data.BehaviourData, PetData[1], PetData[2]); if (GeneratedPet != null) { Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet); Session.SendMessage(new FurniListNotificationComposer(GeneratedPet.PetId, 3)); Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); if (CloudServer.GetGame().GetItemManager().GetItem(320, out ItemData PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), "", ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendMessage(new FurniListNotificationComposer(Food.Id, 1)); } } } break; } } if (Item.Badge != string.Empty) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Badge, true, Session); } Session.SendMessage(new PurchaseOKComposer(Item, Item.Data, Item.Items)); Session.SendMessage(new FurniListUpdateComposer()); }
public void Parse(GameClient Session, ClientPacket Packet) { int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string ExtraData = Packet.PopString(); int Amount = Packet.PopInt(); CatalogPage Page = null; if (!ButterflyEnvironment.GetGame().GetCatalog().TryGetPage(PageId, out Page)) { return; } if (!Page.Enabled || Page.MinimumRank > Session.GetHabbo().Rank) { 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 (Amount < 1 || Amount > 100 || !Item.HaveOffer) { Amount = 1; } int AmountPurchase = Item.Amount > 1 ? Item.Amount : Amount; int TotalCreditsCost = Amount > 1 ? ((Item.CostCredits * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostCredits)) : Item.CostCredits; int TotalPixelCost = Amount > 1 ? ((Item.CostDuckets * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDuckets)) : Item.CostDuckets; int TotalDiamondCost = Amount > 1 ? ((Item.CostDiamonds * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDiamonds)) : Item.CostDiamonds; if (Session.GetHabbo().Credits < TotalCreditsCost || Session.GetHabbo().Duckets < TotalPixelCost || Session.GetHabbo().WibboPoints < TotalDiamondCost) { return; } int LimitedEditionSells = 0; int LimitedEditionStack = 0; #region Create the extradata switch (Item.Data.InteractionType) { case InteractionType.none: ExtraData = ""; break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: int GroupId = 0; if (!int.TryParse(ExtraData, out GroupId)) { return; } if (GroupId == 0) { return; } Group Group = null; if (!ButterflyEnvironment.GetGame().GetGroupManager().TryGetGroup(GroupId, out Group)) { return; } ExtraData = "0;" + Group.Id; break; #region Pet handling case InteractionType.pet: try { string[] Bits = ExtraData.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; } ButterflyEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1); } catch (Exception e) { Logging.LogException((e).ToString()); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(ExtraData)) { Number = 0; } else { Number = Double.Parse(ExtraData); } } catch (Exception e) { Logging.LogException((e).ToString()); } ExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ExtraData; break; case InteractionType.MANNEQUIN: ExtraData = "m" + Convert.ToChar(5) + "ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin"; break; case InteractionType.BADGE_TROC: { string[] BadgeNotAllowed = { "ADM", "GPHWIB", "wibbo.helpeur", "WIBARC", "CRPOFFI", "ZEERSWS", "PRWRD1", "WBI1", "WBI2", "WBI3", "WBI4", "WBI5", "WBI6", "WBI7", "CASINOB" }; if (BadgeNotAllowed.Any(x => x == ExtraData)) { ButterflyEnvironment.GetGame().GetModerationTool().LogStaffEntry(Session.GetHabbo().Id, Session.GetHabbo().Username, 0, string.Empty, "notallowed", "Tentative de création Badge Troc: " + ExtraData); Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.buybadgedisplay.error", Session.Langue)); Session.SendPacket(new PurchaseOKComposer()); return; } if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData)) { Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.buybadgedisplay.error", Session.Langue)); Session.SendPacket(new PurchaseOKComposer()); return; } Session.GetHabbo().GetBadgeComponent().RemoveBadge(ExtraData); Session.SendPacket(Session.GetHabbo().GetBadgeComponent().Serialize()); break; } case InteractionType.BADGE_DISPLAY: if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData)) { Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.buybadgedisplay.error", Session.Langue)); Session.SendPacket(new PurchaseOKComposer()); return; } ExtraData = ExtraData + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Badge)) { Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.buybadge.error", Session.Langue)); Session.SendPacket(new PurchaseOKComposer()); return; } break; } default: ExtraData = ""; break; } #endregion if (Item.IsLimited) { if (Item.LimitedEditionStack <= Item.LimitedEditionSells) { Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.buyltd.error", Session.Langue)); Session.SendPacket(new PurchaseOKComposer()); return; } Item.LimitedEditionSells++; using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", Item.LimitedEditionSells); dbClient.AddParameter("itemId", Item.Id); dbClient.RunQuery(); LimitedEditionSells = Item.LimitedEditionSells; LimitedEditionStack = Item.LimitedEditionStack; } } if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= TotalCreditsCost; Session.SendPacket(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostDuckets > 0) { Session.GetHabbo().Duckets -= TotalPixelCost; Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets)); } if (Item.CostDiamonds > 0) { Session.GetHabbo().WibboPoints -= TotalDiamondCost; Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().WibboPoints, 0, 105)); using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor()) queryreactor.RunQuery("UPDATE users SET vip_points = vip_points - " + TotalDiamondCost + " WHERE id = " + Session.GetHabbo().Id); } Item NewItem = null; switch (Item.Data.Type.ToString().ToLower()) { default: List <Item> GeneratedGenericItems = new List <Item>(); switch (Item.Data.InteractionType) { default: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, LimitedEditionSells, LimitedEditionStack); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.TELEPORT: case InteractionType.ARROW: for (int i = 0; i < AmountPurchase; i++) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(Item.Data, Session.GetHabbo()); if (TeleItems != null) { GeneratedGenericItems.AddRange(TeleItems); } } break; case InteractionType.MOODLIGHT: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateMoodlightData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateMoodlightData(NewItem); } } } break; } foreach (Item PurchasedItem in GeneratedGenericItems) { if (Session.GetHabbo().GetInventoryComponent().TryAddItem(PurchasedItem)) { Session.SendPacket(new FurniListNotificationComposer(PurchasedItem.Id, 1)); } } break; case "r": Bot Bot = BotUtility.CreateBot(Item.Data, Session.GetHabbo().Id); if (Bot != null) { Session.GetHabbo().GetInventoryComponent().TryAddBot(Bot); Session.SendPacket(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); Session.SendPacket(new FurniListNotificationComposer(Bot.Id, 5)); } break; case "p": { string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = PetUtility.CreatePet(Session.GetHabbo().Id, PetData[0], Item.Data.SpriteId, PetData[1], PetData[2]); if (GeneratedPet != null) { Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet); Session.SendPacket(new FurniListNotificationComposer(GeneratedPet.PetId, 3)); Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); ItemData PetFood = null; if (ButterflyEnvironment.GetGame().GetItemManager().GetItem(320, out PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendPacket(new FurniListNotificationComposer(Food.Id, 1)); } } } break; } case "b": { break; } } if (!string.IsNullOrEmpty(Item.Badge) && !Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Badge)) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Badge, true); Session.SendPacket(new ReceiveBadgeComposer(Item.Badge)); Session.SendPacket(new FurniListNotificationComposer(0, 4)); } Session.SendPacket(new PurchaseOKComposer(Item, Item.Data)); }
public void Parse(GameClient Session, ClientPacket Packet) { if (PlusEnvironment.GetSettingsManager().TryGetValue("catalog.enabled") != "1") { Session.SendNotification("The hotel managers have disabled the catalogue"); return; } int PageId = Packet.PopInt(); int ItemId = Packet.PopInt(); string ExtraData = Packet.PopString(); int Amount = Packet.PopInt(); 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 (Amount < 1 || Amount > 100 || !Item.HaveOffer) { Amount = 1; } int AmountPurchase = Item.Amount > 1 ? Item.Amount : Amount; int TotalCreditsCost = Amount > 1 ? ((Item.CostCredits * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostCredits)) : Item.CostCredits; int TotalPixelCost = Amount > 1 ? ((Item.CostPixels * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostPixels)) : Item.CostPixels; int TotalDiamondCost = Amount > 1 ? ((Item.CostDiamonds * Amount) - ((int)Math.Floor((double)Amount / 6) * Item.CostDiamonds)) : Item.CostDiamonds; if (Session.GetHabbo().Credits < TotalCreditsCost || Session.GetHabbo().Duckets < TotalPixelCost || Session.GetHabbo().Diamonds < TotalDiamondCost) { return; } int LimitedEditionSells = 0; int LimitedEditionStack = 0; #region Create the extradata switch (Item.Data.InteractionType) { case InteractionType.NONE: ExtraData = ""; break; case InteractionType.GUILD_ITEM: case InteractionType.GUILD_GATE: break; #region Pet handling case InteractionType.PET: try { string[] Bits = ExtraData.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 (Exception e) { ExceptionLogger.LogException(e); return; } break; #endregion case InteractionType.FLOOR: case InteractionType.WALLPAPER: case InteractionType.LANDSCAPE: Double Number = 0; try { if (string.IsNullOrEmpty(ExtraData)) { Number = 0; } else { Number = Double.Parse(ExtraData, PlusEnvironment.CultureInfo); } } catch (Exception e) { ExceptionLogger.LogException(e); } ExtraData = Number.ToString().Replace(',', '.'); break; // maintain extra data // todo: validate case InteractionType.POSTIT: ExtraData = "FFFF33"; break; case InteractionType.MOODLIGHT: ExtraData = "1,1,1,#000000,255"; break; case InteractionType.TROPHY: ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ExtraData; break; case InteractionType.MANNEQUIN: ExtraData = "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(ExtraData)) { Session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge.")); return; } ExtraData = ExtraData + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; break; case InteractionType.BADGE: { if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Data.ItemName)) { Session.SendPacket(new PurchaseErrorComposer(1)); return; } break; } default: ExtraData = ""; break; } #endregion if (Item.IsLimited) { if (Item.LimitedEditionStack <= Item.LimitedEditionSells) { Session.SendNotification("This item has sold out!\n\n" + "Please note, you have not recieved another item (You have also not been charged for it!)"); Session.SendPacket(new CatalogUpdatedComposer()); Session.SendPacket(new PurchaseOKComposer()); return; } Item.LimitedEditionSells++; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `catalog_items` SET `limited_sells` = @limitSells WHERE `id` = @itemId LIMIT 1"); dbClient.AddParameter("limitSells", Item.LimitedEditionSells); dbClient.AddParameter("itemId", Item.Id); dbClient.RunQuery(); LimitedEditionSells = Item.LimitedEditionSells; LimitedEditionStack = Item.LimitedEditionStack; } } if (Item.CostCredits > 0) { Session.GetHabbo().Credits -= TotalCreditsCost; Session.SendPacket(new CreditBalanceComposer(Session.GetHabbo().Credits)); } if (Item.CostPixels > 0) { Session.GetHabbo().Duckets -= TotalPixelCost; Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));//Love you, Tom. } if (Item.CostDiamonds > 0) { Session.GetHabbo().Diamonds -= TotalDiamondCost; Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); } Item NewItem = null; switch (Item.Data.Type.ToString().ToLower()) { default: List <Item> GeneratedGenericItems = new List <Item>(); switch (Item.Data.InteractionType) { default: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, 0, LimitedEditionSells, LimitedEditionStack); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.GUILD_GATE: case InteractionType.GUILD_ITEM: case InteractionType.GUILD_FORUM: if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase, Convert.ToInt32(ExtraData)); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData, Convert.ToInt32(ExtraData)); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); } } break; case InteractionType.ARROW: case InteractionType.TELEPORT: for (int i = 0; i < AmountPurchase; i++) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(Item.Data, Session.GetHabbo()); if (TeleItems != null) { GeneratedGenericItems.AddRange(TeleItems); } } break; case InteractionType.MOODLIGHT: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateMoodlightData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateMoodlightData(NewItem); } } } break; case InteractionType.TONER: { if (AmountPurchase > 1) { List <Item> Items = ItemFactory.CreateMultipleItems(Item.Data, Session.GetHabbo(), ExtraData, AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); foreach (Item I in Items) { ItemFactory.CreateTonerData(I); } } } else { NewItem = ItemFactory.CreateSingleItemNullable(Item.Data, Session.GetHabbo(), ExtraData, ExtraData); if (NewItem != null) { GeneratedGenericItems.Add(NewItem); ItemFactory.CreateTonerData(NewItem); } } } break; case InteractionType.DEAL: { CatalogDeal deal = null; if (PlusEnvironment.GetGame().GetCatalog().TryGetDeal(Item.Data.BehaviourData, out deal)) { foreach (CatalogItem CatalogItem in deal.ItemDataList.ToList()) { List <Item> Items = ItemFactory.CreateMultipleItems(CatalogItem.Data, Session.GetHabbo(), "", AmountPurchase); if (Items != null) { GeneratedGenericItems.AddRange(Items); } } } break; } case InteractionType.ROOMDEAL: { CatalogDeal deal = null; if (PlusEnvironment.GetGame().GetCatalog().TryGetDeal(Item.Data.BehaviourData, out deal)) { Room room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(deal.RoomId); if (room == null) { Session.SendNotification("There was an error loading this Room Bundle, if this happens again please contact hotel management!"); } RoomData newRoom = PlusEnvironment.GetGame().GetRoomManager().CreateRoom(Session, room.Name, room.Description, room.ModelName, room.Category, 10, room.TradeSettings, room.Wallpaper, room.Floor, room.Landscape, room.WallThickness, room.FloorThickness); if (newRoom == null) { return; } Room myRoom = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(newRoom.Id); if (myRoom != null) { List <Item> Items = ItemLoader.GetItemsForRoom(deal.RoomId, room); Item teleLink = null; foreach (var furni in Items) { if (furni.Data.InteractionType == InteractionType.TELEPORT) { if (teleLink == null) { List <Item> TeleItems = ItemFactory.CreateTeleporterItems(furni.Data, Session.GetHabbo()); if (TeleItems != null && TeleItems.ToList().Count > 1) { myRoom.GetRoomItemHandler().SetFloorItem(Session, TeleItems[0], furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); teleLink = TeleItems[1]; } } else { myRoom.GetRoomItemHandler().SetFloorItem(Session, teleLink, furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); teleLink = null; } } else { NewItem = ItemFactory.CreateSingleItemNullable(furni.Data, Session.GetHabbo(), furni.ExtraData, "", furni.GroupId); if (NewItem != null) { if (NewItem.IsWallItem) { NewItem.wallCoord = furni.wallCoord; myRoom.GetRoomItemHandler().SetWallItem(Session, NewItem); } else { myRoom.GetRoomItemHandler().SetFloorItem(Session, NewItem, furni.GetX, furni.GetY, furni.Rotation, true, true, true, false, furni.GetZ); } } } } Session.GetHabbo().PrepareRoom(myRoom.Id, ""); } } break; } } foreach (Item PurchasedItem in GeneratedGenericItems) { if (Session.GetHabbo().GetInventoryComponent().TryAddItem(PurchasedItem)) { //Session.SendMessage(new FurniListAddComposer(PurchasedItem)); Session.SendPacket(new FurniListNotificationComposer(PurchasedItem.Id, 1)); } } break; case "e": AvatarEffect Effect = null; if (Session.GetHabbo().Effects().HasEffect(Item.Data.SpriteId)) { Effect = Session.GetHabbo().Effects().GetEffectNullable(Item.Data.SpriteId); if (Effect != null) { Effect.AddToQuantity(); } } else { Effect = AvatarEffectFactory.CreateNullable(Session.GetHabbo(), Item.Data.SpriteId, 3600); } if (Effect != null) // && Session.GetHabbo().Effects().TryAdd(Effect)) { Session.SendPacket(new AvatarEffectAddedComposer(Item.Data.SpriteId, 3600)); } break; case "r": Bot Bot = BotUtility.CreateBot(Item.Data, Session.GetHabbo().Id); if (Bot != null) { Session.GetHabbo().GetInventoryComponent().TryAddBot(Bot); Session.SendPacket(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); Session.SendPacket(new FurniListNotificationComposer(Bot.Id, 5)); } else { Session.SendNotification("Oops! There was an error whilst purchasing this bot. It seems that there is no bot data for the bot!"); } break; case "b": { Session.GetHabbo().GetBadgeComponent().GiveBadge(Item.Data.ItemName, true, Session); Session.SendPacket(new FurniListNotificationComposer(0, 4)); break; } case "p": { string[] PetData = ExtraData.Split('\n'); Pet GeneratedPet = PetUtility.CreatePet(Session.GetHabbo().Id, PetData[0], Item.Data.BehaviourData, PetData[1], PetData[2]); if (GeneratedPet != null) { Session.GetHabbo().GetInventoryComponent().TryAddPet(GeneratedPet); Session.SendPacket(new FurniListNotificationComposer(GeneratedPet.PetId, 3)); Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); 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.SendPacket(new FurniListNotificationComposer(Food.Id, 1)); } } } break; } } BadgeDefinition Badge; if (!string.IsNullOrEmpty(Item.Badge) && PlusEnvironment.GetGame().GetBadgeManager().TryGetBadge(Item.Badge, out Badge) && (string.IsNullOrEmpty(Badge.RequiredRight) || Session.GetHabbo().GetPermissions().HasRight(Badge.RequiredRight))) { Session.GetHabbo().GetBadgeComponent().GiveBadge(Badge.Code, true, Session); } Session.SendPacket(new PurchaseOKComposer(Item, Item.Data)); Session.SendPacket(new FurniListUpdateComposer()); }