Exemple #1
0
        internal void HandlePurchase(GameClient Session, int PageId, int ItemId, string ExtraData, int priceAmount, bool IsGift, string GiftUser, string GiftMessage, int GiftSpriteId, int GiftLazo, int GiftColor, bool undef, uint Group)
        {
            if (priceAmount < 1 || priceAmount > 100)
            {
                priceAmount = 1;
            }
            int num = priceAmount;
            int num2 = 0;
            int limtot = 0;
            CatalogPage catalogPage;
            CatalogItem item;
            uint num3;
            checked
            {
                if (priceAmount >= 6)
                {
                    num--;
                }
                if (priceAmount >= 12)
                {
                    num -= 2;
                }
                if (priceAmount >= 18)
                {
                    num -= 2;
                }
                if (priceAmount >= 24)
                {
                    num -= 2;
                }
                if (priceAmount >= 30)
                {
                    num -= 2;
                }
                if (priceAmount >= 36)
                {
                    num -= 2;
                }
                if (priceAmount >= 42)
                {
                    num -= 2;
                }
                if (priceAmount >= 48)
                {
                    num -= 2;
                }
                if (priceAmount >= 54)
                {
                    num -= 2;
                }
                if (priceAmount >= 60)
                {
                    num -= 2;
                }
                if (priceAmount >= 66)
                {
                    num -= 2;
                }
                if (priceAmount >= 72)
                {
                    num -= 2;
                }
                if (priceAmount >= 78)
                {
                    num -= 2;
                }
                if (priceAmount >= 84)
                {
                    num -= 2;
                }
                if (priceAmount >= 90)
                {
                    num -= 2;
                }
                if (priceAmount >= 96)
                {
                    num -= 2;
                }
                if (priceAmount >= 99)
                {
                    num -= 2;
                }
                if (!this.Categories.Contains(PageId) && PageId != -12345678)
                {
                    return;
                }

                if (PageId == -12345678)
                {
                    item = GetItemFromOffer(ItemId);

                    if (item == null)
                    {
                        return;
                    }
                }
                else
                {
                    catalogPage = (CatalogPage)Categories[PageId];
                    if (catalogPage == null || !catalogPage.Enabled || !catalogPage.Visible || Session == null || Session.GetHabbo() == null)
                    {
                        return;
                    }
                    if (catalogPage.MinRank > Session.GetHabbo().Rank || catalogPage.Layout == "sold_ltd_items")
                    {
                        return;
                    }

                    item = catalogPage.GetItem(ItemId);
                    if (item == null)
                    {
                        return;
                    }

                    if (catalogPage.Layout == "vip_buy" || catalogPage.Layout == "club_buy" || HabboClubItems.Contains(item))
                    {
                        string[] array = item.Name.Split(new char[]
				{
					'_'
				});
                        double dayLength;
                        if (item.Name.Contains("DAY"))
                        {
                            dayLength = double.Parse(array[3]);
                        }
                        else
                        {
                            if (item.Name.Contains("MONTH"))
                            {
                                double num4 = double.Parse(array[3]);
                                dayLength = Math.Ceiling((num4 * 31) - 0.205);
                            }
                            else
                            {
                                if (item.Name.Contains("YEAR"))
                                {
                                    double num5 = double.Parse(array[3]);
                                    dayLength = (num5 * 31 * 12);
                                }
                                else
                                {
                                    dayLength = 31;
                                }
                            }
                        }
                        Session.GetHabbo().GetSubscriptionManager().AddSubscription(dayLength);
                        return;
                    }
                }

                if (item.Name == "room_ad_plus_badge")
                {
                    return;
                }

                if (item.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription)
                {
                    ServerMessage serverMessage = new ServerMessage(Outgoing.CatalogPurchaseNotAllowedMessageComposer);
                    serverMessage.AppendInt32(1);
                    Session.SendMessage(serverMessage);
                    return;
                }
                else if (item.Name.Contains("guild_forum"))
                {
                    uint GroupId;
                    if (!uint.TryParse(ExtraData, out GroupId))
                    {
                        Session.SendNotif("Your group forum couldn't be created by an unknown error. Please report it.");
                        return;
                    }
                    else
                    {
                        Guild Grap = CyberEnvironment.GetGame().GetGroupManager().GetGroup(GroupId);
                        if (Grap == null)
                        {
                            Session.SendNotif("Your group forum couldn't be created by an unknown error. Please report it");
                            return;
                        }
                        else if (!Grap.HasForum && Grap.CreatorId == Session.GetHabbo().Id)
                        {
                            Grap.HasForum = true;
                            CyberEnvironment.GetGame().GetClientManager().SendSuperNotif("Congratulations!", "You successfully purchased a Forum for your group.", "admin", Session, "event:groupforum/" + Grap.Id, "Enter my new Group Forum", false, false);
                            Grap.UpdateForum();
                        }
                        else if (Grap.CreatorId != Session.GetHabbo().Id && !Grap.HasForum)
                        {
                            Session.SendNotif("Uhm, looks like you're not the owner of the group. Anyway, you received a Group Forum Terminal, which would work only when the owner of the group buys a forum.");
                        }
                    }
                }
                bool flag = false;
                foreach (uint current in item.Items.Keys)
                {
                    if (item.GetBaseItem(current).InteractionType == InteractionType.pet1 || item.GetBaseItem(current).InteractionType == InteractionType.pet2 || item.GetBaseItem(current).InteractionType == InteractionType.pet3 || item.GetBaseItem(current).InteractionType == InteractionType.pet4 || item.GetBaseItem(current).InteractionType == InteractionType.pet5 || item.GetBaseItem(current).InteractionType == InteractionType.pet6 || item.GetBaseItem(current).InteractionType == InteractionType.pet7 || item.GetBaseItem(current).InteractionType == InteractionType.pet8 || item.GetBaseItem(current).InteractionType == InteractionType.pet9 || item.GetBaseItem(current).InteractionType == InteractionType.pet10 || item.GetBaseItem(current).InteractionType == InteractionType.pet11 || item.GetBaseItem(current).InteractionType == InteractionType.pet12 || item.GetBaseItem(current).InteractionType == InteractionType.pet13 || item.GetBaseItem(current).InteractionType == InteractionType.pet14 || item.GetBaseItem(current).InteractionType == InteractionType.pet15 || item.GetBaseItem(current).InteractionType == InteractionType.pet16 || item.GetBaseItem(current).InteractionType == InteractionType.pet17 || item.GetBaseItem(current).InteractionType == InteractionType.pet18 || item.GetBaseItem(current).InteractionType == InteractionType.pet19 || item.GetBaseItem(current).InteractionType == InteractionType.pet20 || item.GetBaseItem(current).InteractionType == InteractionType.pet21 || item.GetBaseItem(current).InteractionType == InteractionType.pet22 || item.GetBaseItem(current).InteractionType == InteractionType.pet23 || item.GetBaseItem(current).InteractionType == InteractionType.pet24 || item.GetBaseItem(current).InteractionType == InteractionType.pet25 || item.GetBaseItem(current).InteractionType == InteractionType.pet26)
                    {
                        flag = true;
                    }
                }
                if (!flag && (item.CreditsCost * num < 0 || item.DucketsCost * num < 0 || item.BelCreditsCost * num < 0 || item.LoyaltyCost * num < 0))
                {
                    return;
                }
                if (item.IsLimited)
                {
                    num = 1;
                    priceAmount = 1;
                    if (item.LimitedSelled >= item.LimitedStack)
                    {
                        Session.SendMessage(new ServerMessage(Outgoing.CatalogLimitedItemSoldOutMessageComposer));
                        return;
                    }
                    item.LimitedSelled++;
                    using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                    {
                        queryreactor.runFastQuery(string.Concat(new object[]
						{
							"UPDATE catalog_items SET limited_sells = ",
							item.LimitedSelled,
							" WHERE id = ",
							item.Id
						}));
                        num2 = item.LimitedSelled;
                        limtot = item.LimitedStack;
                    }
                }
                else
                {
                    if (IsGift & priceAmount > 1)
                    {
                        num = 1;
                        priceAmount = 1;
                    }
                }
                num3 = 0u;
                if (Session.GetHabbo().Credits < item.CreditsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().ActivityPoints < item.DucketsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().BelCredits < item.BelCreditsCost * num)
                {
                    return;
                }
                if (Session.GetHabbo().BelCredits < item.LoyaltyCost * num)
                {
                    return;
                }
                if (item.CreditsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().Credits -= item.CreditsCost * num;
                    Session.GetHabbo().UpdateCreditsBalance();
                }
                if (item.DucketsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().ActivityPoints -= item.DucketsCost * num;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                }
                if (item.BelCreditsCost > 0 && !IsGift)
                {
                    Session.GetHabbo().BelCredits -= item.BelCreditsCost * num;
                    Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
                if (item.LoyaltyCost > 0 && !IsGift)
                {
                    Session.GetHabbo().BelCredits -= item.LoyaltyCost * num;
                    Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
            }

            

            checked
            {
                foreach (uint current2 in item.Items.Keys)
                {
                    if (IsGift)
                    {
                        if ((DateTime.Now - Session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
                        {
                            Session.SendNotif("You're purchasing gifts too fast! Please wait 15 seconds, then you purchase another gift.");
                            return;
                        }

                        if (!item.GetBaseItem(current2).AllowGift)
                        {
                            return;
                        }
                        DataRow row;
                        using (IQueryAdapter queryreactor3 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                        {
                            queryreactor3.setQuery("SELECT id FROM users WHERE username = @gift_user");
                            queryreactor3.addParameter("gift_user", GiftUser);
                            row = queryreactor3.getRow();
                        }
                        if (row == null)
                        {
                            Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftErrorMessageComposer);
                            Session.GetMessageHandler().GetResponse().AppendString(GiftUser);
                            Session.GetMessageHandler().SendResponse();
                            return;
                        }
                        num3 = Convert.ToUInt32(row["id"]);
                        if (num3 == 0u)
                        {
                            Session.GetMessageHandler().GetResponse().Init(Outgoing.GiftErrorMessageComposer);
                            Session.GetMessageHandler().GetResponse().AppendString(GiftUser);
                            Session.GetMessageHandler().SendResponse();
                            return;
                        }
                        if (item.CreditsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().Credits -= item.CreditsCost * num;
                            Session.GetHabbo().UpdateCreditsBalance();
                        }
                        if (item.DucketsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().ActivityPoints -= item.DucketsCost * num;
                            Session.GetHabbo().UpdateActivityPointsBalance();
                        }
                        if (item.BelCreditsCost > 0 && IsGift)
                        {
                            Session.GetHabbo().BelCredits -= item.BelCreditsCost * num;
                            Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                        }
                        if (item.LoyaltyCost > 0 && IsGift)
                        {
                            Session.GetHabbo().BelCredits -= item.LoyaltyCost * num;
                            Session.GetHabbo().UpdateSeasonalCurrencyBalance();
                        }
                    }
                    if (IsGift && item.GetBaseItem(current2).Type == 'e')
                    {
                        Session.SendNotif("You can't send effects as gifts.");
                        return;
                    }
                    string text = "";
                    InteractionType interactionType = item.GetBaseItem(current2).InteractionType;
                    switch (interactionType)
                    {
                        case InteractionType.none:
                            ExtraData = "";
                            break;
                        case InteractionType.gate:
                        case InteractionType.bed:
                        case InteractionType.scoreboard:
                        case InteractionType.vendingmachine:
                        case InteractionType.alert:
                        case InteractionType.onewaygate:
                        case InteractionType.loveshuffler:
                        case InteractionType.habbowheel:
                        case InteractionType.dice:
                        case InteractionType.bottle:
                        case InteractionType.hopper:
                        case InteractionType.teleport:
                        case InteractionType.pet:
                        case InteractionType.pool:
                        case InteractionType.roller:
                        case InteractionType.fbgate:
                            goto IL_DF5;
                        case InteractionType.postit:
                            ExtraData = "FFFF33";
                            break;
                        case InteractionType.roomeffect:
                            {
                                double num6 = 0.0;
                                try
                                {
                                    if (string.IsNullOrEmpty(ExtraData))
                                    {
                                        num6 = 0.0;
                                    }
                                    else
                                    {
                                        num6 = double.Parse(ExtraData, CyberEnvironment.cultureInfo);
                                    }
                                }
                                catch (Exception pException)
                                {
                                    Logging.HandleException(pException, "Catalog.HandlePurchase: " + ExtraData);
                                }
                                ExtraData = TextHandling.GetString(num6);
                                break;
                            }
                        case InteractionType.dimmer:
                            ExtraData = "1,1,1,#000000,255";
                            break;
                        case InteractionType.trophy:
                            ExtraData = string.Concat(new object[]
						{
							Session.GetHabbo().Username,
							Convert.ToChar(9),
							DateTime.Now.Day,
							"-",
							DateTime.Now.Month,
							"-",
							DateTime.Now.Year,
							Convert.ToChar(9),
							ExtraData
						});
                            break;
                        case InteractionType.rentals:
                            goto IL_C41;
                        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:
                        case InteractionType.pet14:
                        case InteractionType.pet15:
                        case InteractionType.pet16:
                        case InteractionType.pet17:
                        case InteractionType.pet18:
                        case InteractionType.pet19:
                        case InteractionType.pet20:
                        case InteractionType.pet21:
                        case InteractionType.pet22:
                        case InteractionType.pet23:
                        case InteractionType.pet24:
                        case InteractionType.pet25:
                        case InteractionType.pet26:
                            try
                            {
                                string[] array2 = ExtraData.Split(new char[]
							{
								'\n'
							});
                                string petName = array2[0];
                                string text2 = array2[1];
                                string text3 = array2[2];
                                int.Parse(text2);
                                if (!Catalog.CheckPetName(petName))
                                {
                                    return;
                                }
                                if (text2.Length != 1)
                                {
                                    return;
                                }
                                if (text3.Length != 6)
                                {
                                    return;
                                }
                                CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_PetLover", 1, false);
                                break;
                            }
                            catch (Exception ex)
                            {
                                Logging.WriteLine(ex.ToString(), ConsoleColor.Gray);
                                Logging.HandleException(ex, "Catalog.HandlePurchase");
                                return;
                            }
                        default:
                            switch (interactionType)
                            {
                                case InteractionType.mannequin:
                                    ExtraData = string.Concat(new object[]
								{
									"m",
									Convert.ToChar(5),
									"ch-215-92.lg-3202-1322-73",
									Convert.ToChar(5),
									"Mannequin"
								});
                                    break;
                                case InteractionType.vip_gate:
                                case InteractionType.mystery_box:
                                case InteractionType.youtubetv:
                                case InteractionType.tilestackmagic:
                                case InteractionType.tent:
                                case InteractionType.bedtent:
                                    goto IL_DF5;
                                case InteractionType.badge_display:
                                    if (!Session.GetHabbo().GetBadgeComponent().HasBadge(ExtraData))
                                        ExtraData = "UMAD";
                                    break;
                                case InteractionType.fbgate:
                                    ExtraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62";
                                    break;


                                case InteractionType.pinata:
                                case InteractionType.runwaysage:
                                case InteractionType.shower:
                                    ExtraData = "0";
                                    break;
                                case InteractionType.groupforumterminal:
                                case InteractionType.gld_item:
                                case InteractionType.gld_gate:
                                case InteractionType.poster:
                                    break;
                                case InteractionType.moplaseed:
                                    ExtraData = new Random().Next(0, 12).ToString();
                                    break;
                                case InteractionType.musicdisc:
                                    text = SongManager.GetCodeById((uint)item.songID);
                                    SongData song = SongManager.GetSongById((uint)item.songID);
                                    ExtraData = string.Concat(new object[]
							    {
								    Session.GetHabbo().Username,
								    '\n',
								    DateTime.Now.Year,
								    '\n',
								    DateTime.Now.Month,
								    '\n',
								    DateTime.Now.Day,
								    '\n',
								    song.LengthSeconds,
								    '\n',
								    song.Name
							    });
                                    break;
                                default:
                                    goto IL_DF5;
                            }
                            break;
                    }
                IL_DFC:
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateInventoryMessageComposer);
                    Session.GetMessageHandler().SendResponse();
                    Session.SendMessage(CatalogPacket.PurchaseOK());
                    if (IsGift)
                    {
                        Item itemBySprite = CyberEnvironment.GetGame().GetItemManager().GetItemBySprite(GiftSpriteId, 's');

                        if (itemBySprite == null)
                        {
                            return;
                        }

                        GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(num3);
                        uint num7;
                        using (IQueryAdapter queryreactor4 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                        {
                            queryreactor4.setQuery(string.Concat(new object[]
							{
								"INSERT INTO items (base_item,user_id) VALUES (",
								itemBySprite.ItemId,
								", ",
								num3,
								")"
							}));
                            num7 = (uint)queryreactor4.insertQuery();
                            queryreactor4.setQuery(string.Concat(new object[]
							{
								"INSERT INTO user_gifts (gift_id,item_id,extradata,giver_name,message,ribbon,color,gift_sprite,show_sender,rare_id) VALUES (",
								num7,
								", ",
								item.GetBaseItem(current2).ItemId,
								",@extradata, @name, @message,",
								GiftLazo,
								",",
								GiftColor,
								",",
								GiftSpriteId,
								",",
								undef ? 1 : 0,
								",",
								num2,
								")"
							}));
                            queryreactor4.addParameter("extradata", ExtraData);
                            queryreactor4.addParameter("name", GiftUser);
                            queryreactor4.addParameter("message", GiftMessage);
                            queryreactor4.runQuery();
                            if (Session.GetHabbo().Id != num3)
                            {
                                queryreactor4.runFastQuery(string.Concat(new object[]
								{
									"UPDATE user_stats SET gifts_given = gifts_given + 1 WHERE id = ",
									Session.GetHabbo().Id,
									" LIMIT 1;UPDATE user_stats SET gifts_received = gifts_received + 1 WHERE id = ",
									num3,
									" LIMIT 1"
								}));
                            }
                        }
                        if (clientByUserID.GetHabbo().Id != Session.GetHabbo().Id)
                        {
                            CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_GiftGiver", 1, false);
                            CyberEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.GIFT_OTHERS, 0u);
                        }
                        if (clientByUserID != null)
                        {
                            UserItem userItem = clientByUserID.GetHabbo().GetInventoryComponent().AddNewItem(num7, itemBySprite.ItemId, string.Concat(new object[]
							{
								Session.GetHabbo().Id,
								(char)9,
								GiftMessage,
								(char)9,
								GiftLazo,
								(char)9,
								GiftColor,
                                (char)9,
                                ((undef) ? "1" : "0"),
                                (char)9,
                                Session.GetHabbo().Username,
                                (char)9,
                                Session.GetHabbo().Look,
                                (char)9,
                                item.Name
							}), 0u, false, false, 0, 0, "");
                            if (clientByUserID.GetHabbo().Id != Session.GetHabbo().Id)
                            {
                                CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserID, "ACH_GiftReceiver", 1, false);
                            }
                        }
                        Session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;
                        continue;
                    }
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.NewInventoryObjectMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendInt32(1);
                    int i = 1;
                    if (item.GetBaseItem(current2).Type.ToString().ToLower().Equals("s"))
                    {
                        if (item.GetBaseItem(current2).InteractionType == InteractionType.pet1 || item.GetBaseItem(current2).InteractionType == InteractionType.pet2 || item.GetBaseItem(current2).InteractionType == InteractionType.pet3 || item.GetBaseItem(current2).InteractionType == InteractionType.pet4 || item.GetBaseItem(current2).InteractionType == InteractionType.pet5 || item.GetBaseItem(current2).InteractionType == InteractionType.pet6 || item.GetBaseItem(current2).InteractionType == InteractionType.pet7 || item.GetBaseItem(current2).InteractionType == InteractionType.pet8 || item.GetBaseItem(current2).InteractionType == InteractionType.pet9 || item.GetBaseItem(current2).InteractionType == InteractionType.pet10 || item.GetBaseItem(current2).InteractionType == InteractionType.pet11 || item.GetBaseItem(current2).InteractionType == InteractionType.pet12 || item.GetBaseItem(current2).InteractionType == InteractionType.pet13 || item.GetBaseItem(current2).InteractionType == InteractionType.pet14 || item.GetBaseItem(current2).InteractionType == InteractionType.pet15 || item.GetBaseItem(current2).InteractionType == InteractionType.pet16 || item.GetBaseItem(current2).InteractionType == InteractionType.pet17 || item.GetBaseItem(current2).InteractionType == InteractionType.pet18)
                        {
                            i = 3;
                        }
                        else
                        {
                            i = 1;
                        }
                    }
                    Session.GetMessageHandler().GetResponse().AppendInt32(i);
                    List<UserItem> list = this.DeliverItems(Session, item.GetBaseItem(current2), priceAmount * item.Items[current2], ExtraData, num2, limtot, text);
                    Session.GetMessageHandler().GetResponse().AppendInt32(list.Count);
                    foreach (UserItem current3 in list)
                    {
                        Session.GetMessageHandler().GetResponse().AppendUInt(current3.Id);
                    }
                    Session.GetMessageHandler().SendResponse();
                    Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                    if (item.GetBaseItem(current2).InteractionType == InteractionType.pet1 || item.GetBaseItem(current2).InteractionType == InteractionType.pet2 || item.GetBaseItem(current2).InteractionType == InteractionType.pet3 || item.GetBaseItem(current2).InteractionType == InteractionType.pet4 || item.GetBaseItem(current2).InteractionType == InteractionType.pet5 || item.GetBaseItem(current2).InteractionType == InteractionType.pet6 || item.GetBaseItem(current2).InteractionType == InteractionType.pet7 || item.GetBaseItem(current2).InteractionType == InteractionType.pet8 || item.GetBaseItem(current2).InteractionType == InteractionType.pet9 || item.GetBaseItem(current2).InteractionType == InteractionType.pet10 || item.GetBaseItem(current2).InteractionType == InteractionType.pet11 || item.GetBaseItem(current2).InteractionType == InteractionType.pet12 || item.GetBaseItem(current2).InteractionType == InteractionType.pet13 || item.GetBaseItem(current2).InteractionType == InteractionType.pet14 || item.GetBaseItem(current2).InteractionType == InteractionType.pet15 || item.GetBaseItem(current2).InteractionType == InteractionType.pet16 || item.GetBaseItem(current2).InteractionType == InteractionType.pet17 || item.GetBaseItem(current2).InteractionType == InteractionType.pet18)
                    {
                        Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
                        continue;
                    }
                    continue;
                IL_C41:
                    ExtraData = item.ExtraData;
                    goto IL_DFC;
                IL_DF5:
                    ExtraData = "";
                    goto IL_DFC;
                }
                if (item.Badge.Length >= 1)
                {
                    Session.GetHabbo().GetBadgeComponent().GiveBadge(item.Badge, true, Session, false);
                }
            }
        }
		public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
		{
			if (Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
			{
				string[] array = Item.ExtraData.Split(new char[]
				{
					Convert.ToChar(5)
				});
				Session.GetHabbo().Gender = array[0].ToUpper();
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Clear();
				string[] array2 = array[1].Split(new char[]
				{
					'.'
				});
				for (int i = 0; i < array2.Length; i++)
				{
					string text = array2[i];
					string[] array3 = Session.GetHabbo().Look.Split(new char[]
					{
						'.'
					});
					for (int j = 0; j < array3.Length; j++)
					{
						string text2 = array3[j];
						if (text2.Split(new char[]
						{
							'-'
						})[0] == text.Split(new char[]
						{
							'-'
						})[0])
						{
							if (dictionary.ContainsKey(text2.Split(new char[]
							{
								'-'
							})[0]) && !dictionary.ContainsValue(text))
							{
								dictionary.Remove(text2.Split(new char[]
								{
									'-'
								})[0]);
								dictionary.Add(text2.Split(new char[]
								{
									'-'
								})[0], text);
							}
							else
							{
								if (!dictionary.ContainsKey(text2.Split(new char[]
								{
									'-'
								})[0]) && !dictionary.ContainsValue(text))
								{
									dictionary.Add(text2.Split(new char[]
									{
										'-'
									})[0], text);
								}
							}
						}
						else
						{
							if (!dictionary.ContainsKey(text2.Split(new char[]
							{
								'-'
							})[0]))
							{
								dictionary.Add(text2.Split(new char[]
								{
									'-'
								})[0], text2);
							}
						}
					}
				}
				string text3 = "";
				foreach (string current in dictionary.Values)
				{
					text3 = text3 + current + ".";
				}
				Session.GetHabbo().Look = text3.TrimEnd(new char[]
				{
					'.'
				});
				using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
				{
					queryreactor.setQuery("UPDATE users SET look = @look, gender = @gender WHERE id = " + Session.GetHabbo().Id);
					queryreactor.addParameter("look", Session.GetHabbo().Look);
					queryreactor.addParameter("gender", Session.GetHabbo().Gender);
					queryreactor.runQuery();
				}
				Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserDataMessageComposer);
				Session.GetMessageHandler().GetResponse().AppendInt32(-1);
				Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
				Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
				Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
				Session.GetMessageHandler().GetResponse().AppendInt32(Session.GetHabbo().AchievementPoints);
				Session.GetMessageHandler().SendResponse();
				RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
				ServerMessage serverMessage = new ServerMessage(Outgoing.UpdateUserDataMessageComposer);
				serverMessage.AppendInt32(roomUserByHabbo.VirtualId);
				serverMessage.AppendString(Session.GetHabbo().Look);
				serverMessage.AppendString(Session.GetHabbo().Gender.ToLower());
				serverMessage.AppendString(Session.GetHabbo().Motto);
				serverMessage.AppendInt32(Session.GetHabbo().AchievementPoints);
				Session.GetHabbo().CurrentRoom.SendMessage(serverMessage);
			}
		}
		internal bool ProgressUserAchievement(GameClient Session, string AchievementGroup, int ProgressAmount, bool FromZero = false)
		{
			if (!this.Achievements.ContainsKey(AchievementGroup) || Session == null)
			{
				return false;
			}
			Achievement achievement = null;
			achievement = this.Achievements[AchievementGroup];
			UserAchievement userAchievement = Session.GetHabbo().GetAchievementData(AchievementGroup);
			if (userAchievement == null)
			{
				userAchievement = new UserAchievement(AchievementGroup, 0, 0);
				Session.GetHabbo().Achievements.Add(AchievementGroup, userAchievement);
			}
			int count = achievement.Levels.Count;
			if (userAchievement != null && userAchievement.Level == count)
			{
				return false;
			}
			checked
			{
				int num = (userAchievement != null) ? (userAchievement.Level + 1) : 1;
				if (num > count)
				{
					num = count;
				}
				AchievementLevel targetLevelData = achievement.Levels[num];
				int num2 = 0;
				if (FromZero)
				{
					num2 = ProgressAmount;
				}
				else
				{
					num2 = ((userAchievement != null) ? (userAchievement.Progress + ProgressAmount) : ProgressAmount);
				}
				int num3 = (userAchievement != null) ? userAchievement.Level : 0;
				int num4 = num3 + 1;
				if (num4 > count)
				{
					num4 = count;
				}
				if (num2 >= targetLevelData.Requirement)
				{
					num3++;
					num4++;
					int arg_E6_0 = num2 - targetLevelData.Requirement;
					num2 = 0;
					if (num == 1)
					{
						Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
					}
					else
					{
						Session.GetHabbo().GetBadgeComponent().RemoveBadge(Convert.ToString(AchievementGroup + (num - 1)), Session);
						Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
					}
					if (num4 > count)
					{
						num4 = count;
					}
					Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
					Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
					Session.GetHabbo().UpdateActivityPointsBalance();
					Session.SendMessage(AchievementUnlockedComposer.Compose(achievement, num, targetLevelData.RewardPoints, targetLevelData.RewardPixels));
					using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
					{
						queryreactor.setQuery(string.Concat(new object[]
						{
							"REPLACE INTO user_achievement VALUES (",
							Session.GetHabbo().Id,
							", @group, ",
							num3,
							", ",
							num2,
							")"
						}));
						queryreactor.addParameter("group", AchievementGroup);
						queryreactor.runQuery();
					}
					userAchievement.Level = num3;
					userAchievement.Progress = num2;
					Session.GetHabbo().AchievementPoints += targetLevelData.RewardPoints;
					Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
					Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
					Session.GetHabbo().UpdateActivityPointsBalance();
					Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
					AchievementLevel targetLevelData2 = achievement.Levels[num4];
					Session.SendMessage(AchievementProgressComposer.Compose(achievement, num4, targetLevelData2, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));
					Talent talent = null;
					if (CyberEnvironment.GetGame().GetTalentManager().TryGetTalent(AchievementGroup, out talent))
					{
						CyberEnvironment.GetGame().GetTalentManager().CompleteUserTalent(Session, talent);
					}
					return true;
				}
				userAchievement.Level = num3;
				userAchievement.Progress = num2;
				using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
				{
					queryreactor2.setQuery(string.Concat(new object[]
					{
						"REPLACE INTO user_achievement VALUES (",
						Session.GetHabbo().Id,
						", @group, ",
						num3,
						", ",
						num2,
						")"
					}));
					queryreactor2.addParameter("group", AchievementGroup);
					queryreactor2.runQuery();
				}
				Session.SendMessage(AchievementProgressComposer.Compose(achievement, num, targetLevelData, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));

                Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserDataMessageComposer);
                Session.GetMessageHandler().GetResponse().AppendInt32(-1);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
                Session.GetMessageHandler().GetResponse().AppendInt32(Session.GetHabbo().AchievementPoints);
                Session.GetMessageHandler().SendResponse();
                return false;
			}
		}
        internal void RemoveUserFromRoom(GameClient Session, bool NotifyClient, bool NotifyKick)
        {
            try
            {
                if (Session == null || Session.GetHabbo() == null || this.room == null)
                {
                    return;
                }
                Session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.runFastQuery(string.Concat(new object[]
					{
						"UPDATE user_roomvisits SET exit_timestamp = '",
						CyberEnvironment.GetUnixTimestamp(),
						"' WHERE room_id = '",
						this.room.RoomId,
						"' AND user_id = '",
						Session.GetHabbo().Id,
						"' ORDER BY entry_timestamp DESC LIMIT 1"
					}));
                }
                RoomUser roomUserByHabbo = this.GetRoomUserByHabbo(Session.GetHabbo().Id);
                if (roomUserByHabbo == null)
                {
                    return;
                }
                if (NotifyKick || (NotifyClient && NotifyKick))
                {
                    Room room = CyberEnvironment.GetGame().GetRoomManager().GetRoom(roomUserByHabbo.RoomId);
                    DynamicRoomModel model = room.GetGameMap().Model;
                    roomUserByHabbo.MoveTo(model.DoorX, model.DoorY);
                    roomUserByHabbo.CanWalk = false;
                    Session.GetMessageHandler().GetResponse().Init(Outgoing.RoomErrorMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendInt32(4008);
                    Session.GetMessageHandler().SendResponse();


                    Session.GetMessageHandler().GetResponse().Init(Outgoing.OutOfRoomMessageComposer);
                    Session.GetMessageHandler().GetResponse().AppendShort(2);
                    Session.GetMessageHandler().SendResponse();
                }
                else
                {
                    if (NotifyClient && !NotifyKick)
                    {
                        ServerMessage serverMessage = new ServerMessage(Outgoing.UserIsPlayingFreezeMessageComposer);
                        serverMessage.AppendBoolean(roomUserByHabbo.team != Team.none);
                        roomUserByHabbo.GetClient().SendMessage(serverMessage);
                        Session.GetMessageHandler().GetResponse().Init(Outgoing.OutOfRoomMessageComposer);
                        Session.GetMessageHandler().GetResponse().AppendShort(2);
                        Session.GetMessageHandler().SendResponse();
                    }
                }
                if (roomUserByHabbo != null)
                {
                    if (roomUserByHabbo.team != Team.none)
                    {
                        this.room.GetTeamManagerForBanzai().OnUserLeave(roomUserByHabbo);
                        this.room.GetTeamManagerForFreeze().OnUserLeave(roomUserByHabbo);
                    }
                    if (roomUserByHabbo.RidingHorse)
                    {
                        roomUserByHabbo.RidingHorse = false;
                        RoomUser Horse = this.GetRoomUserByVirtualId((int)roomUserByHabbo.HorseID);
                        if (Horse != null)
                        {
                            Horse.RidingHorse = false;
                            Horse.HorseID = 0u;
                        }
                    }
                    if (roomUserByHabbo.IsLyingDown || roomUserByHabbo.IsSitting)
                    {
                        roomUserByHabbo.IsSitting = false;
                        roomUserByHabbo.IsLyingDown = false;
                    }
                    this.RemoveRoomUser(roomUserByHabbo);
                    if (Session.GetHabbo() != null && !roomUserByHabbo.IsSpectator)
                    {
                        if (roomUserByHabbo.CurrentItemEffect != ItemEffectType.None)
                        {
                            roomUserByHabbo.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                        }
                        if (Session.GetHabbo() != null)
                        {
                            if (this.room.HasActiveTrade(Session.GetHabbo().Id))
                            {
                                this.room.TryStopTrade(Session.GetHabbo().Id);
                            }
                            Session.GetHabbo().CurrentRoomId = 0u;
                            if (Session.GetHabbo().GetMessenger() != null)
                            {
                                Session.GetHabbo().GetMessenger().OnStatusChanged(true);
                            }
                        }
                        DateTime now = DateTime.Now;
                        using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                        {

                            if (Session.GetHabbo() != null)
                            {
                                queryreactor2.runFastQuery(string.Concat(new object[]
								{
									"UPDATE user_roomvisits SET exit_timestamp = '",
									CyberEnvironment.GetUnixTimestamp(),
									"' WHERE room_id = '",
									this.room.RoomId,
									"' AND user_id = '",
									Session.GetHabbo().Id,
									"' ORDER BY exit_timestamp DESC LIMIT 1"
								}));
                            }
                        }
                    }
                    this.usersByUserID.Remove(roomUserByHabbo.UserID);
                    if (Session.GetHabbo() != null)
                    {
                        this.usersByUsername.Remove(Session.GetHabbo().Username.ToLower());
                    }
                    roomUserByHabbo.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logging.LogCriticalException("Error during removing user from room:" + ex.ToString());
            }
        }