Esempio n. 1
0
        public void CheckCreditsTimer()
        {
            try
            {
                _creditsTickUpdate--;

                if (_creditsTickUpdate <= 0)
                {
                    int CreditUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.credit_reward"));
                    int DucketUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.ducket_reward"));

                    SubscriptionData SubData = null;
                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_vipRank, out SubData))
                    {
                        CreditUpdate += SubData.Credits;
                        DucketUpdate += SubData.Duckets;
                    }

                    _credits += CreditUpdate;
                    _duckets += DucketUpdate;

                    _client.SendPacket(new CreditBalanceComposer(_credits));
                    _client.SendPacket(new HabboActivityPointNotificationComposer(_duckets, DucketUpdate));

                    CreditsUpdateTick = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));
                }
            }
            catch { }
        }
Esempio n. 2
0
 public void CheckCreditsTimer()
 {
     try
     {
         CreditsUpdateTick--;
         if (CreditsUpdateTick <= 0)
         {
             var creditUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager()
                                                .TryGetValue("user.currency_scheduler.credit_reward"));
             var ducketUpdate = Convert.ToInt32(PlusEnvironment.GetSettingsManager()
                                                .TryGetValue("user.currency_scheduler.ducket_reward"));
             SubscriptionData subData = null;
             if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(VipRank, out subData))
             {
                 creditUpdate += subData.Credits;
                 ducketUpdate += subData.Duckets;
             }
             Credits += creditUpdate;
             Duckets += ducketUpdate;
             _client.SendPacket(new CreditBalanceComposer(Credits));
             _client.SendPacket(new HabboActivityPointNotificationComposer(Duckets, ducketUpdate));
             CreditsUpdateTick =
                 Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));
         }
     }
     catch
     {
     }
 }
Esempio n. 3
0
 public override void Compose(ServerPacket packet)
 {
     packet.WriteInteger(Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("messenger.buddy_limit")));//Friends max.
     packet.WriteInteger(300);
     packet.WriteInteger(800);
     packet.WriteInteger(0); // category count
 }
Esempio n. 4
0
        public void Parse(HabboHotel.GameClients.GameClient session, ClientPacket packet)
        {
            string Name        = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            string Description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            int    RoomId      = packet.PopInt();
            int    Colour1     = packet.PopInt();
            int    Colour2     = packet.PopInt();
            int    Unknown     = packet.PopInt();

            int groupCost = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("catalog.group.purchase.cost"));

            if (session.GetHabbo().Credits < groupCost)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("A group costs " + groupCost + " credits! You only have " + session.GetHabbo().Credits + "!"));
                return;
            }
            else
            {
                session.GetHabbo().Credits -= groupCost;
                session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits));
            }

            RoomData Room = null;

            if (!RoomFactory.TryGetData(RoomId, out Room))
            {
                return;
            }

            if (Room == null || Room.OwnerId != session.GetHabbo().Id || Room.Group != null)
            {
                return;
            }

            string Badge = string.Empty;

            for (int i = 0; i < 5; i++)
            {
                Badge += BadgePartUtility.WorkBadgeParts(i == 0, packet.PopInt().ToString(), packet.PopInt().ToString(), packet.PopInt().ToString());
            }

            Group Group = null;

            if (!PlusEnvironment.GetGame().GetGroupManager().TryCreateGroup(session.GetHabbo(), Name, Description, RoomId, Badge, Colour1, Colour2, out Group))
            {
                session.SendNotification("An error occured whilst trying to create this group.\n\nTry again. If you get this message more than once, report it at the link below.\r\rhttp://boonboards.com");
                return;
            }

            session.SendPacket(new PurchaseOKComposer());

            Room.Group = Group;

            if (session.GetHabbo().CurrentRoomId != Room.Id)
            {
                session.SendPacket(new RoomForwardComposer(Room.Id));
            }

            session.SendPacket(new NewGroupInfoComposer(RoomId, Group.Id));
        }
Esempio n. 5
0
        public override void Compose(ServerPacket packet)
        {
            packet.WriteInteger(Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("catalog.group.purchase.cost"))); //Price

            packet.WriteInteger(Rooms.Count);                                                                                      //Room count that the user has.
            foreach (RoomData room in Rooms)
            {
                packet.WriteInteger(room.Id);  //Room Id
                packet.WriteString(room.Name); //Room Name
                packet.WriteBoolean(false);    //What?
            }

            packet.WriteInteger(5);
            packet.WriteInteger(5);
            packet.WriteInteger(11);
            packet.WriteInteger(4);

            packet.WriteInteger(6);
            packet.WriteInteger(11);
            packet.WriteInteger(4);

            packet.WriteInteger(0);
            packet.WriteInteger(0);
            packet.WriteInteger(0);

            packet.WriteInteger(0);
            packet.WriteInteger(0);
            packet.WriteInteger(0);

            packet.WriteInteger(0);
            packet.WriteInteger(0);
            packet.WriteInteger(0);
        }
Esempio n. 6
0
        public GroupCreationWindowComposer(ICollection <RoomData> rooms)
            : base(ServerPacketHeader.GroupCreationWindowMessageComposer)
        {
            base.WriteInteger(Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("catalog.group.purchase.cost"))); //Price

            base.WriteInteger(rooms.Count);                                                                                      //Room count that the user has.
            foreach (RoomData room in rooms)
            {
                base.WriteInteger(room.Id);  //Room Id
                base.WriteString(room.Name); //Room Name
                base.WriteBoolean(false);    //What?
            }

            base.WriteInteger(5);
            base.WriteInteger(5);
            base.WriteInteger(11);
            base.WriteInteger(4);

            base.WriteInteger(6);
            base.WriteInteger(11);
            base.WriteInteger(4);

            base.WriteInteger(0);
            base.WriteInteger(0);
            base.WriteInteger(0);

            base.WriteInteger(0);
            base.WriteInteger(0);
            base.WriteInteger(0);

            base.WriteInteger(0);
            base.WriteInteger(0);
            base.WriteInteger(0);
        }
 public MessengerInitComposer()
     : base(ServerPacketHeader.MessengerInitMessageComposer)
 {
     base.WriteInteger(Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("messenger.buddy_limit")));//Friends max.
     base.WriteInteger(300);
     base.WriteInteger(800);
     base.WriteInteger(0); // category count
 }
Esempio n. 8
0
 public RoomPromotion(string Name, string Desc, int CategoryId)
 {
     this.Name        = Name;
     Description      = Desc;
     TimestampStarted = PlusEnvironment.GetUnixTimestamp();
     TimestampExpires = PlusEnvironment.GetUnixTimestamp() +
                        Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.promotion.lifespan")) * 60;
     this.CategoryId = CategoryId;
 }
Esempio n. 9
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            if (!Room.CheckRights(Session, true))
            {
                return;
            }

            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.exchangeables.enabled") != "1")
            {
                Session.SendNotification("The hotel managers have temporarilly disabled exchanging!");
                return;
            }

            Item Exchange = Room.GetRoomItemHandler().GetItem(Packet.PopInt());

            if (Exchange == null)
            {
                return;
            }

            if (Exchange.Data.InteractionType != InteractionType.EXCHANGE)
            {
                return;
            }


            int Value = Exchange.Data.BehaviourData;

            if (Value > 0)
            {
                Session.GetHabbo().Credits += Value;
                Session.SendPacket(new CreditBalanceComposer(Session.GetHabbo().Credits));
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @exchangeId LIMIT 1");
                dbClient.AddParameter("exchangeId", Exchange.Id);
                dbClient.RunQuery();
            }

            Session.SendPacket(new FurniListUpdateComposer());
            Room.GetRoomItemHandler().RemoveFurniture(null, Exchange.Id, false);
            Session.GetHabbo().GetInventoryComponent().RemoveItem(Exchange.Id);
        }
Esempio n. 10
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (!session.GetHabbo().InRoom)
            {
                return;
            }

            Room room;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().CurrentRoomId, out room))
            {
                return;
            }

            if (!room.CheckRights(session, true))
            {
                return;
            }

            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.exchangeables.enabled") != "1")
            {
                session.SendNotification("The hotel managers have temporarilly disabled exchanging!");
                return;
            }

            var exchange = room.GetRoomItemHandler().GetItem(packet.PopInt());

            if (exchange == null)
            {
                return;
            }

            if (exchange.Data.InteractionType != InteractionType.Exchange)
            {
                return;
            }

            var value = exchange.Data.BehaviourData;

            if (value > 0)
            {
                session.GetHabbo().Credits += value;
                session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits));
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @exchangeId LIMIT 1");
                dbClient.AddParameter("exchangeId", exchange.Id);
                dbClient.RunQuery();
            }

            session.SendPacket(new FurniListUpdateComposer());
            room.GetRoomItemHandler().RemoveFurniture(null, exchange.Id, false);
            session.GetHabbo().GetInventoryComponent().RemoveItem(exchange.Id);
        }
Esempio n. 11
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            var name        = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            var description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            var roomId      = packet.PopInt();
            var colour1     = packet.PopInt();
            var colour2     = packet.PopInt();
            var unknown     = packet.PopInt();

            var groupCost = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("catalog.group.purchase.cost"));

            if (session.GetHabbo().Credits < groupCost)
            {
                session.SendPacket(new BroadcastMessageAlertComposer("A group costs " + groupCost + " credits! You only have " + session.GetHabbo().Credits + "!"));
                return;
            }

            session.GetHabbo().Credits -= groupCost;
            session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits));

            var room = PlusEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomId);

            if (room == null || room.OwnerId != session.GetHabbo().Id || room.Group != null)
            {
                return;
            }

            var badge = string.Empty;

            for (var i = 0; i < 5; i++)
            {
                badge += BadgePartUtility.WorkBadgeParts(i == 0, packet.PopInt().ToString(), packet.PopInt().ToString(), packet.PopInt().ToString());
            }

            Group group = null;

            if (!PlusEnvironment.GetGame().GetGroupManager().TryCreateGroup(session.GetHabbo(), name, description, roomId, badge, colour1, colour2, out group))
            {
                session.SendNotification(
                    "An error occured whilst trying to create this group.\n\nTry again. If you get this message more than once, report it at the link below.\r\rhttp://boonboards.com");
                return;
            }

            session.SendPacket(new PurchaseOkComposer());

            room.Group = group;

            if (session.GetHabbo().CurrentRoomId != room.Id)
            {
                session.SendPacket(new RoomForwardComposer(room.Id));
            }

            session.SendPacket(new NewGroupInfoComposer(roomId, group.Id));
        }
Esempio n. 12
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            Group group;

            if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(packet.PopInt(), out group))
            {
                session.SendNotification("Oops, we couldn't find that group!");
                return;
            }

            if (group.CreatorId != session.GetHabbo().Id&& !session.GetHabbo().GetPermissions().HasRight("group_delete_override"))  //Maybe a FUSE check for staff override?
            {
                session.SendNotification("Oops, only the group owner can delete a group!");
                return;
            }

            if (group.MemberCount >= Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("group.delete.member.limit")) &&
                !session.GetHabbo().GetPermissions().HasRight("group_delete_limit_override"))
            {
                session.SendNotification("Oops, your group exceeds the maximum amount of members (" +
                                         Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("group.delete.member.limit")) +
                                         ") a group can exceed before being eligible for deletion. Seek assistance from a staff member.");
                return;
            }

            var room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(group.RoomId);

            if (room != null)
            {
                room.Group          = null;
                room.RoomData.Group = null; //I'm not sure if this is needed or not, becauseof inheritance, but oh well.
            }

            //Remove it from the cache.
            PlusEnvironment.GetGame().GetGroupManager().DeleteGroup(group.Id);

            //Now the :S stuff.
            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.RunQuery("DELETE FROM `groups` WHERE `id` = '" + group.Id + "'");
                dbClient.RunQuery("DELETE FROM `group_memberships` WHERE `group_id` = '" + group.Id + "'");
                dbClient.RunQuery("DELETE FROM `group_requests` WHERE `group_id` = '" + group.Id + "'");
                dbClient.RunQuery("UPDATE `rooms` SET `group_id` = '0' WHERE `group_id` = '" + group.Id + "' LIMIT 1");
                dbClient.RunQuery("UPDATE `user_stats` SET `groupid` = '0' WHERE `groupid` = '" + group.Id + "' LIMIT 1");
                dbClient.RunQuery("DELETE FROM `items_groups` WHERE `group_id` = '" + group.Id + "'");
            }

            //Unload it last.
            PlusEnvironment.GetGame().GetRoomManager().UnloadRoom(room, true);

            //Say hey!
            session.SendNotification("You have successfully deleted your group.");
        }
Esempio n. 13
0
        public void ProcessItems()
        {
            List <Item> UserOne = Users[0].OfferedItems.Values.ToList();
            List <Item> UserTwo = Users[1].OfferedItems.Values.ToList();

            RoomUser RoomUserOne = Users[0].RoomUser;
            RoomUser RoomUserTwo = Users[1].RoomUser;

            string logUserOne = "";
            string logUserTwo = "";

            if (RoomUserOne == null || RoomUserOne.GetClient() == null || RoomUserOne.GetClient().GetHabbo() == null || RoomUserOne.GetClient().GetHabbo().GetInventoryComponent() == null)
            {
                return;
            }

            if (RoomUserTwo == null || RoomUserTwo.GetClient() == null || RoomUserTwo.GetClient().GetHabbo() == null || RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent() == null)
            {
                return;
            }

            foreach (Item Item in UserOne)
            {
                Item I = RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().GetItem(Item.Id);

                if (I == null)
                {
                    SendPacket(new BroadcastMessageAlertComposer("Error! Trading Failed!"));
                    return;
                }
            }

            foreach (Item Item in UserTwo)
            {
                Item I = RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().GetItem(Item.Id);

                if (I == null)
                {
                    SendPacket(new BroadcastMessageAlertComposer("Error! Trading Failed!"));
                    return;
                }
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                foreach (Item Item in UserOne)
                {
                    logUserOne += Item.Id + ";";
                    RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
                    if (Item.Data.InteractionType == InteractionType.EXCHANGE && PlusEnvironment.GetSettingsManager().TryGetValue("trading.auto_exchange_redeemables") == "1")
                    {
                        RoomUserTwo.GetClient().GetHabbo().Credits += Item.Data.BehaviourData;
                        RoomUserTwo.GetClient().SendPacket(new CreditBalanceComposer(RoomUserTwo.GetClient().GetHabbo().Credits));

                        dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @id LIMIT 1");
                        dbClient.AddParameter("id", Item.Id);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        if (RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item))
                        {
                            RoomUserTwo.GetClient().SendPacket(new FurniListAddComposer(Item));
                            RoomUserTwo.GetClient().SendPacket(new FurniListNotificationComposer(Item.Id, 1));

                            dbClient.SetQuery("UPDATE `items` SET `user_id` = @user WHERE id=@id LIMIT 1");
                            dbClient.AddParameter("user", RoomUserTwo.UserId);
                            dbClient.AddParameter("id", Item.Id);
                            dbClient.RunQuery();
                        }
                    }
                }

                foreach (Item Item in UserTwo)
                {
                    logUserTwo += Item.Id + ";";
                    RoomUserTwo.GetClient().GetHabbo().GetInventoryComponent().RemoveItem(Item.Id);
                    if (Item.Data.InteractionType == InteractionType.EXCHANGE && PlusEnvironment.GetSettingsManager().TryGetValue("trading.auto_exchange_redeemables") == "1")
                    {
                        RoomUserOne.GetClient().GetHabbo().Credits += Item.Data.BehaviourData;
                        RoomUserOne.GetClient().SendPacket(new CreditBalanceComposer(RoomUserOne.GetClient().GetHabbo().Credits));

                        dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @id LIMIT 1");
                        dbClient.AddParameter("id", Item.Id);
                        dbClient.RunQuery();
                    }
                    else
                    {
                        if (RoomUserOne.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item))
                        {
                            RoomUserOne.GetClient().SendPacket(new FurniListAddComposer(Item));
                            RoomUserOne.GetClient().SendPacket(new FurniListNotificationComposer(Item.Id, 1));

                            dbClient.SetQuery("UPDATE `items` SET `user_id` = @user WHERE id=@id LIMIT 1");
                            dbClient.AddParameter("user", RoomUserOne.UserId);
                            dbClient.AddParameter("id", Item.Id);
                            dbClient.RunQuery();
                        }
                    }
                }

                dbClient.SetQuery("INSERT INTO `logs_client_trade` VALUES(null, @1id, @2id, @1items, @2items, UNIX_TIMESTAMP())");
                dbClient.AddParameter("1id", RoomUserOne.UserId);
                dbClient.AddParameter("2id", RoomUserTwo.UserId);
                dbClient.AddParameter("1items", logUserOne);
                dbClient.AddParameter("2items", logUserTwo);
                dbClient.RunQuery();
            }
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            int    PageId      = Packet.PopInt();
            int    ItemId      = Packet.PopInt();
            string Data        = Packet.PopString();
            string GiftUser    = StringCharFilter.Escape(Packet.PopString());
            string GiftMessage = StringCharFilter.Escape(Packet.PopString().Replace(Convert.ToChar(5), ' '));
            int    SpriteId    = Packet.PopInt();
            int    Ribbon      = Packet.PopInt();
            int    Colour      = Packet.PopInt();
            bool   dnow        = Packet.PopBoolean();

            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.gifts.enabled") != "1")
            {
                Session.SendNotification("The hotel managers have disabled gifting");
                return;
            }

            /*if (PlusEnvironment.GetGame().GetCatalog().CatalogFlatOffers.ContainsKey(ItemId) && PageId < 0)
             * {
             *  PageId = PlusEnvironment.GetGame().GetCatalog().CatalogFlatOffers[ItemId];
             *
             *  CatalogPage P = null;
             *  if (!PlusEnvironment.GetGame().GetCatalog().Pages.TryGetValue(PageId, out P))
             *      PageId = 0;
             * }*/

            CatalogPage Page = null;

            if (!PlusEnvironment.GetGame().GetCatalog().TryGetPage(PageId, out Page))
            {
                return;
            }

            if (!Page.Enabled || !Page.Visible || Page.MinimumRank > Session.GetHabbo().Rank || (Page.MinimumVIP > Session.GetHabbo().VIPRank&& Session.GetHabbo().Rank == 1))
            {
                return;
            }

            CatalogItem Item = null;

            if (!Page.Items.TryGetValue(ItemId, out Item))
            {
                if (Page.ItemOffers.ContainsKey(ItemId))
                {
                    Item = (CatalogItem)Page.ItemOffers[ItemId];
                    if (Item == null)
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            if (!ItemUtility.CanGiftItem(Item))
            {
                return;
            }

            ItemData PresentData = null;

            if (!PlusEnvironment.GetGame().GetItemManager().GetGift(SpriteId, out PresentData) || PresentData.InteractionType != InteractionType.GIFT)
            {
                return;
            }

            if (Session.GetHabbo().Credits < Item.CostCredits)
            {
                Session.SendPacket(new PresentDeliverErrorMessageComposer(true, false));
                return;
            }

            if (Session.GetHabbo().Duckets < Item.CostPixels)
            {
                Session.SendPacket(new PresentDeliverErrorMessageComposer(false, true));
                return;
            }

            Habbo Habbo = PlusEnvironment.GetHabboByUsername(GiftUser);

            if (Habbo == null)
            {
                Session.SendPacket(new GiftWrappingErrorComposer());
                return;
            }

            if (!Habbo.AllowGifts)
            {
                Session.SendNotification("Oops, this user doesn't allow gifts to be sent to them!");
                return;
            }

            if ((DateTime.Now - Session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
            {
                Session.SendNotification("You're purchasing gifts too fast! Please wait 15 seconds!");

                Session.GetHabbo().GiftPurchasingWarnings += 1;
                if (Session.GetHabbo().GiftPurchasingWarnings >= 25)
                {
                    Session.GetHabbo().SessionGiftBlocked = true;
                }
                return;
            }

            if (Session.GetHabbo().SessionGiftBlocked)
            {
                return;
            }


            string ED = GiftUser + Convert.ToChar(5) + GiftMessage + Convert.ToChar(5) + Session.GetHabbo().Id + Convert.ToChar(5) + Item.Data.Id + Convert.ToChar(5) + SpriteId + Convert.ToChar(5) + Ribbon + Convert.ToChar(5) + Colour;

            int NewItemId = 0;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                //Insert the dummy item.
                dbClient.SetQuery("INSERT INTO `items` (`base_item`,`user_id`,`extra_data`) VALUES (@baseId, @habboId, @extra_data)");
                dbClient.AddParameter("baseId", PresentData.Id);
                dbClient.AddParameter("habboId", Habbo.Id);
                dbClient.AddParameter("extra_data", ED);
                NewItemId = Convert.ToInt32(dbClient.InsertQuery());

                string ItemExtraData = null;
                switch (Item.Data.InteractionType)
                {
                case InteractionType.NONE:
                    ItemExtraData = "";
                    break;

                    #region Pet handling

                case InteractionType.PET:

                    try
                    {
                        string[] Bits    = Data.Split('\n');
                        string   PetName = Bits[0];
                        string   Race    = Bits[1];
                        string   Color   = Bits[2];

                        int.Parse(Race);     // to trigger any possible errors

                        if (PetUtility.CheckPetName(PetName))
                        {
                            return;
                        }

                        if (Race.Length > 2)
                        {
                            return;
                        }

                        if (Color.Length != 6)
                        {
                            return;
                        }

                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_PetLover", 1);
                    }
                    catch
                    {
                        return;
                    }

                    break;

                    #endregion

                case InteractionType.FLOOR:
                case InteractionType.WALLPAPER:
                case InteractionType.LANDSCAPE:

                    Double Number = 0;
                    try
                    {
                        if (string.IsNullOrEmpty(Data))
                        {
                            Number = 0;
                        }
                        else
                        {
                            Number = Double.Parse(Data, PlusEnvironment.CultureInfo);
                        }
                    }
                    catch
                    {
                    }

                    ItemExtraData = Number.ToString().Replace(',', '.');
                    break;     // maintain extra data // todo: validate

                case InteractionType.POSTIT:
                    ItemExtraData = "FFFF33";
                    break;

                case InteractionType.MOODLIGHT:
                    ItemExtraData = "1,1,1,#000000,255";
                    break;

                case InteractionType.TROPHY:
                    ItemExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + Data;
                    break;

                case InteractionType.MANNEQUIN:
                    ItemExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin";
                    break;

                case InteractionType.BADGE_DISPLAY:
                    if (!Session.GetHabbo().GetBadgeComponent().HasBadge(Data))
                    {
                        Session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge."));
                        return;
                    }

                    ItemExtraData = Data + Convert.ToChar(9) + Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;
                    break;

                default:
                    ItemExtraData = Data;
                    break;
                }

                //Insert the present, forever.
                dbClient.SetQuery("INSERT INTO `user_presents` (`item_id`,`base_id`,`extra_data`) VALUES (@itemId, @baseId, @extra_data)");
                dbClient.AddParameter("itemId", NewItemId);
                dbClient.AddParameter("baseId", Item.Data.Id);
                dbClient.AddParameter("extra_data", (string.IsNullOrEmpty(ItemExtraData) ? "" : ItemExtraData));
                dbClient.RunQuery();

                //Here we're clearing up a record, this is dumb, but okay.
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @deleteId LIMIT 1");
                dbClient.AddParameter("deleteId", NewItemId);
                dbClient.RunQuery();
            }


            Item GiveItem = ItemFactory.CreateGiftItem(PresentData, Habbo, ED, ED, NewItemId, 0, 0);
            if (GiveItem != null)
            {
                GameClient Receiver = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Habbo.Id);
                if (Receiver != null)
                {
                    Receiver.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem);
                    Receiver.SendPacket(new FurniListNotificationComposer(GiveItem.Id, 1));
                    Receiver.SendPacket(new PurchaseOKComposer());
                    Receiver.SendPacket(new FurniListAddComposer(GiveItem));
                    Receiver.SendPacket(new FurniListUpdateComposer());
                }

                if (Habbo.Id != Session.GetHabbo().Id&& !string.IsNullOrWhiteSpace(GiftMessage))
                {
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_GiftGiver", 1);
                    if (Receiver != null)
                    {
                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Receiver, "ACH_GiftReceiver", 1);
                    }
                    PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.GIFT_OTHERS);
                }
            }

            Session.SendPacket(new PurchaseOKComposer(Item, PresentData));

            if (Item.CostCredits > 0)
            {
                Session.GetHabbo().Credits -= Item.CostCredits;
                Session.SendPacket(new CreditBalanceComposer(Session.GetHabbo().Credits));
            }

            if (Item.CostPixels > 0)
            {
                Session.GetHabbo().Duckets -= Item.CostPixels;
                Session.SendPacket(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Session.GetHabbo().Duckets));
            }

            Session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;
        }
Esempio n. 15
0
        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());
        }
Esempio n. 16
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool") && Room.CheckMute(Session))
            {
                Session.SendWhisper("Oops, you're currently muted.");
                return;
            }

            if (PlusEnvironment.GetUnixTimestamp() < Session.GetHabbo().FloodTime&& Session.GetHabbo().FloodTime != 0)
            {
                return;
            }

            string Params  = Packet.PopString();
            string ToUser  = Params.Split(' ')[0];
            string Message = Params.Substring(ToUser.Length + 1);
            int    Colour  = Packet.PopInt();

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            RoomUser User2 = Room.GetRoomUserManager().GetRoomUserByHabbo(ToUser);

            if (User2 == null)
            {
                return;
            }

            if (Session.GetHabbo().TimeMuted > 0)
            {
                Session.SendPacket(new MutedComposer(Session.GetHabbo().TimeMuted));
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override"))
            {
                Message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Message);
            }

            ChatStyle Style = null;

            if (!PlusEnvironment.GetGame().GetChatManager().GetChatStyles().TryGetStyle(Colour, out Style) || (Style.RequiredRight.Length > 0 && !Session.GetHabbo().GetPermissions().HasRight(Style.RequiredRight)))
            {
                Colour = 0;
            }

            User.LastBubble = Session.GetHabbo().CustomBubbleId == 0 ? Colour : Session.GetHabbo().CustomBubbleId;

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                int MuteTime;
                if (User.IncrementAndCheckFlood(out MuteTime))
                {
                    Session.SendPacket(new FloodControlComposer(MuteTime));
                    return;
                }
            }

            if (!User2.GetClient().GetHabbo().ReceiveWhispers&& !Session.GetHabbo().GetPermissions().HasRight("room_whisper_override"))
            {
                Session.SendWhisper("Oops, this user has their whispers disabled!");
                return;
            }

            PlusEnvironment.GetGame().GetChatManager().GetLogs().StoreChatlog(new ChatlogEntry(Session.GetHabbo().Id, Room.Id, "<Whisper to " + ToUser + ">: " + Message, UnixTimestamp.GetNow(), Session.GetHabbo(), Room));

            if (PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckBannedWords(Message))
            {
                Session.GetHabbo().BannedPhraseCount++;
                if (Session.GetHabbo().BannedPhraseCount >= (Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.chat.filter.banned_phrases.chances"))))
                {
                    PlusEnvironment.GetGame().GetModerationManager().BanUser("System", HabboHotel.Moderation.ModerationBanType.Username, Session.GetHabbo().Username, "Spamming banned phrases (" + Message + ")", (PlusEnvironment.GetUnixTimestamp() + 78892200));
                    Session.Disconnect();
                    return;
                }
                Session.SendPacket(new WhisperComposer(User.VirtualId, Message, 0, User.LastBubble));
                return;
            }


            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SocialChat);

            User.UnIdle();
            User.GetClient().SendPacket(new WhisperComposer(User.VirtualId, Message, 0, User.LastBubble));

            if (User2 != null && !User2.IsBot && User2.UserId != User.UserId)
            {
                if (!User2.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(Session.GetHabbo().Id))
                {
                    User2.GetClient().SendPacket(new WhisperComposer(User.VirtualId, Message, 0, User.LastBubble));
                }
            }

            List <RoomUser> ToNotify = Room.GetRoomUserManager().GetRoomUserByRank(2);

            if (ToNotify.Count > 0)
            {
                foreach (RoomUser user in ToNotify)
                {
                    if (user != null && user.HabboId != User2.HabboId && user.HabboId != User.HabboId)
                    {
                        if (user.GetClient() != null && user.GetClient().GetHabbo() != null && !user.GetClient().GetHabbo().IgnorePublicWhispers)
                        {
                            user.GetClient().SendPacket(new WhisperComposer(User.VirtualId, "[Whisper to " + ToUser + "] " + Message, 0, User.LastBubble));
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int ItemId = 0;

            string[] Data = null;

            string RawData = Packet.PopString();

            Data = RawData.Split(' ');

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            if (!HasRights)
            {
                Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")))
            {
                Session.SendNotification("You cannot have more than " + Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")) + " items in a room!");
                return;
            }
            else if (Item.Data.InteractionType == InteractionType.EXCHANGE && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("You cannot place exchange items in other people's rooms!");
                return;
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendNotification("You can only have one background moodlight per room!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("You can only have one background toner per room!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("You can only have one hopper per room!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }

            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (Session.GetHabbo().Id == Room.OwnerId)
                    {
                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                    }

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }
                }
                else
                {
                    Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;

                if (TrySetWallItem(CorrectedData, out WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            if (Session.GetHabbo().Id == Room.OwnerId)
                            {
                                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                            }
                        }
                    }
                    catch
                    {
                        Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                        return;
                    }
                }
                else
                {
                    Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }
Esempio n. 18
0
        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());
        }
Esempio n. 19
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (!session.Habbo.InRoom)
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.Habbo.CurrentRoomId, out Room room))
            {
                return;
            }

            if (room.AllowPets == 0 && !room.CheckRights(session, true) || !room.CheckRights(session, true))
            {
                session.SendPacket(new RoomErrorNotifComposer(1));
                return;
            }

            if (room.GetRoomUserManager().PetCount > Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.pets.placement_limit")))
            {
                session.SendPacket(new RoomErrorNotifComposer(2));//5 = I have too many.
                return;
            }

            if (!session.Habbo.GetInventoryComponent().TryGetPet(packet.PopInt(), out Pet pet))
            {
                return;
            }

            if (pet == null)
            {
                return;
            }

            if (pet.PlacedInRoom)
            {
                session.SendNotification("This pet is already in the room?");
                return;
            }

            int x = packet.PopInt();
            int y = packet.PopInt();

            if (!room.GetGameMap().CanWalk(x, y, false))
            {
                session.SendPacket(new RoomErrorNotifComposer(4));
                return;
            }

            if (room.GetRoomUserManager().TryGetPet(pet.PetId, out RoomUser oldPet))
            {
                room.GetRoomUserManager().RemoveBot(oldPet.VirtualId, false);
            }

            pet.X = x;
            pet.Y = y;

            pet.PlacedInRoom = true;
            pet.RoomId       = room.RoomId;

            List <RandomSpeech> rndSpeechList = new List <RandomSpeech>();
            RoomBot             roomBot       = new RoomBot(pet.PetId, pet.RoomId, "pet", "freeroam", pet.Name, "", pet.Look, x, y, 0, 0, 0, 0, 0, 0, ref rndSpeechList, "", 0, pet.OwnerId, false, 0, false, 0);

            room.GetRoomUserManager().DeployBot(roomBot, pet);

            pet.DBState = PetDatabaseUpdateState.NeedsUpdate;
            room.GetRoomUserManager().UpdatePets();

            if (!session.Habbo.GetInventoryComponent().TryRemovePet(pet.PetId, out Pet toRemove))
            {
                Log.Error("Error whilst removing pet: " + toRemove.PetId);
                return;
            }

            session.SendPacket(new PetInventoryComposer(session.Habbo.GetInventoryComponent().GetPets()));
        }
Esempio n. 20
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null || !session.GetHabbo().InRoom)
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.GetHabbo().CurrentRoomId, out var room))
            {
                return;
            }

            var rawData = packet.PopString();
            var data    = rawData.Split(' ');

            if (!int.TryParse(data[0], out var itemId))
            {
                return;
            }

            var hasRights = room.CheckRights(session, false, true);

            if (!hasRights)
            {
                session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            var item = session.GetHabbo().GetInventoryComponent().GetItem(itemId);

            if (item == null)
            {
                return;
            }

            if (room.GetRoomItemHandler().GetWallAndFloor.Count() > Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")))
            {
                session.SendNotification("You cannot have more than " + Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")) +
                                         " items in a room!");
                return;
            }

            if (item.Data.InteractionType == InteractionType.Exchange && room.OwnerId != session.GetHabbo().Id&&
                !session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                session.SendNotification("You cannot place exchange items in other people's rooms!");
                return;
            }

            //TODO: Make neat.
            switch (item.GetBaseItem().InteractionType)
            {
            case InteractionType.Moodlight:
            {
                var moodData = room.MoodlightData;
                if (moodData != null && room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    session.SendNotification("You can only have one background moodlight per room!");
                    return;
                }

                break;
            }

            case InteractionType.Toner:
            {
                var tonerData = room.TonerData;
                if (tonerData != null && room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    session.SendNotification("You can only have one background toner per room!");
                    return;
                }

                break;
            }

            case InteractionType.Hopper:
            {
                if (room.GetRoomItemHandler().HopperCount > 0)
                {
                    session.SendNotification("You can only have one hopper per room!");
                    return;
                }

                break;
            }

            case InteractionType.Tent:
            case InteractionType.TentSmall:
            {
                room.AddTent(item.Id);
                break;
            }
            }

            if (!item.IsWallItem)
            {
                if (data.Length < 4)
                {
                    return;
                }

                int y;

                if (!int.TryParse(data[1], out var x))
                {
                    return;
                }

                if (!int.TryParse(data[2], out y))
                {
                    return;
                }

                if (!int.TryParse(data[3], out var rotation))
                {
                    return;
                }

                var roomItem = new Item(item.Id, room.RoomId, item.BaseItem, item.ExtraData, x, y, 0, rotation, session.GetHabbo().Id, item.GroupId, item.LimitedNo,
                                        item.LimitedTot, string.Empty, room);

                if (room.GetRoomItemHandler().SetFloorItem(session, roomItem, x, y, rotation, true, false, true))
                {
                    session.GetHabbo().GetInventoryComponent().RemoveItem(itemId);

                    if (session.GetHabbo().Id == room.OwnerId)
                    {
                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_RoomDecoFurniCount", 1);
                    }

                    if (!roomItem.IsWired)
                    {
                        return;
                    }

                    try
                    {
                        room.GetWired().LoadWiredBox(roomItem);
                    }
                    catch
                    {
                        Console.WriteLine(item.GetBaseItem().InteractionType);
                    }
                }
                else
                {
                    session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                }
            }
            else if (item.IsWallItem)
            {
                var correctedData = new string[data.Length - 1];

                for (var i = 1; i < data.Length; i++)
                {
                    correctedData[i - 1] = data[i];
                }

                if (TrySetWallItem(correctedData, out var wallPos))
                {
                    try
                    {
                        var roomItem = new Item(item.Id, room.RoomId, item.BaseItem, item.ExtraData, 0, 0, 0, 0, session.GetHabbo().Id, item.GroupId, item.LimitedNo,
                                                item.LimitedTot, wallPos, room);

                        if (room.GetRoomItemHandler().SetWallItem(session, roomItem))
                        {
                            session.GetHabbo().GetInventoryComponent().RemoveItem(itemId);
                            if (session.GetHabbo().Id == room.OwnerId)
                            {
                                PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_RoomDecoFurniCount", 1);
                            }
                        }
                    }
                    catch
                    {
                        session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    }
                }
                else
                {
                    session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                }
            }
        }
Esempio n. 21
0
        public bool TryAuthenticate(string authTicket)
        {
            try
            {
                UserData userData = UserDataFactory.GetUserData(authTicket, out byte errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect();
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(MachineId, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().MachineBanCheck(MachineId))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }

                if (userData.user != null)
                {
                    if (PlusEnvironment.GetGame().GetModerationManager().IsBanned(userData.user.Username, out _))
                    {
                        if (PlusEnvironment.GetGame().GetModerationManager().UsernameBanCheck(userData.user.Username))
                        {
                            Disconnect();
                            return(false);
                        }
                    }
                }
                #endregion

                if (userData.user == null) //Possible NPE
                {
                    return(false);
                }

                PlusEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.user.Username);
                _habbo = userData.user;
                if (_habbo != null)
                {
                    userData.user.Init(this, userData);

                    SendPacket(new AuthenticationOKComposer());
                    SendPacket(new AvatarEffectsComposer(_habbo.Effects().GetAllEffects));
                    SendPacket(new NavigatorSettingsComposer(_habbo.HomeRoom));
                    SendPacket(new FavouritesComposer(userData.user.FavoriteRooms));
                    SendPacket(new FigureSetIdsComposer(_habbo.GetClothing().GetClothingParts));
                    SendPacket(new UserRightsComposer(_habbo.Rank));
                    SendPacket(new AvailabilityStatusComposer());
                    SendPacket(new AchievementScoreComposer(_habbo.GetStats().AchievementPoints));
                    SendPacket(new BuildersClubMembershipComposer());
                    SendPacket(new CfhTopicsInitComposer(PlusEnvironment.GetGame().GetModerationManager().UserActionPresets));

                    SendPacket(new BadgeDefinitionsComposer(PlusEnvironment.GetGame().GetAchievementManager().Achievements));
                    SendPacket(new SoundSettingsComposer(_habbo.ClientVolume, _habbo.ChatPreference, _habbo.AllowMessengerInvites, _habbo.FocusPreference, FriendBarStateUtility.GetInt(_habbo.FriendbarState)));
                    //SendMessage(new TalentTrackLevelComposer());

                    if (GetHabbo().GetMessenger() != null)
                    {
                        GetHabbo().GetMessenger().OnStatusChanged(true);
                    }

                    if (!string.IsNullOrEmpty(MachineId))
                    {
                        if (_habbo.MachineId != MachineId)
                        {
                            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                            {
                                dbClient.SetQuery("UPDATE `users` SET `machine_id` = @MachineId WHERE `id` = @id LIMIT 1");
                                dbClient.AddParameter("MachineId", MachineId);
                                dbClient.AddParameter("id", _habbo.Id);
                                dbClient.RunQuery();
                            }
                        }

                        _habbo.MachineId = MachineId;
                    }

                    if (PlusEnvironment.GetGame().GetPermissionManager().TryGetGroup(_habbo.Rank, out PermissionGroup group))
                    {
                        if (!String.IsNullOrEmpty(group.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(group.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(group.Badge, true, this);
                            }
                        }
                    }

                    if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(_habbo.VIPRank, out SubscriptionData subData))
                    {
                        if (!String.IsNullOrEmpty(subData.Badge))
                        {
                            if (!_habbo.GetBadgeComponent().HasBadge(subData.Badge))
                            {
                                _habbo.GetBadgeComponent().GiveBadge(subData.Badge, true, this);
                            }
                        }
                    }

                    if (!PlusEnvironment.GetGame().GetCacheManager().ContainsUser(_habbo.Id))
                    {
                        PlusEnvironment.GetGame().GetCacheManager().GenerateUser(_habbo.Id);
                    }

                    _habbo.Look = PlusEnvironment.GetFigureManager().ProcessFigure(_habbo.Look, _habbo.Gender, _habbo.GetClothing().GetClothingParts, true);
                    _habbo.InitProcess();

                    if (userData.user.GetPermissions().HasRight("mod_tickets"))
                    {
                        SendPacket(new ModeratorInitComposer(
                                       PlusEnvironment.GetGame().GetModerationManager().UserMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().RoomMessagePresets,
                                       PlusEnvironment.GetGame().GetModerationManager().GetTickets));
                    }

                    if (PlusEnvironment.GetSettingsManager().TryGetValue("user.login.message.enabled") == "1")
                    {
                        SendPacket(new MotdNotificationComposer(PlusEnvironment.GetLanguageManager().TryGetValue("user.login.message")));
                    }

                    PlusEnvironment.GetGame().GetRewardManager().CheckRewards(this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
            return(false);
        }
Esempio n. 22
0
        public Habbo(int Id, string Username, int Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, int HomeRoom,
                     bool HasFriendRequestsDisabled, int LastOnline, bool AppearOffline, bool HideInRoom, double CreateDate, int Diamonds,
                     string machineID, string clientVolume, bool ChatPreference, bool FocusPreference, bool PetsMuted, bool BotsMuted, bool AdvertisingReportBlocked, double LastNameChange,
                     int GOTWPoints, bool IgnoreInvites, double TimeMuted, double TradingLock, bool AllowGifts, int FriendBarState, bool DisableForcedEffects, bool AllowMimic, int VIPRank)
        {
            _id             = Id;
            _username       = Username;
            _rank           = Rank;
            _motto          = Motto;
            _look           = Look;
            _gender         = Gender.ToLower();
            _footballLook   = PlusEnvironment.FilterFigure(Look.ToLower());
            _footballGender = Gender.ToLower();
            _credits        = Credits;
            _duckets        = ActivityPoints;
            _diamonds       = Diamonds;
            _gotwPoints     = GOTWPoints;
            _homeRoom       = HomeRoom;
            _lastOnline     = LastOnline;
            _accountCreated = CreateDate;
            _clientVolume   = new List <int>();
            foreach (string Str in clientVolume.Split(','))
            {
                int Val = 0;
                if (int.TryParse(Str, out Val))
                {
                    _clientVolume.Add(int.Parse(Str));
                }
                else
                {
                    _clientVolume.Add(100);
                }
            }

            _lastNameChange  = LastNameChange;
            _machineId       = machineID;
            _chatPreference  = ChatPreference;
            _focusPreference = FocusPreference;
            _isExpert        = IsExpert == true;

            _appearOffline         = AppearOffline;
            _allowTradingRequests  = true;                      //TODO
            _allowUserFollowing    = true;                      //TODO
            _allowFriendRequests   = HasFriendRequestsDisabled; //TODO
            _allowMessengerInvites = IgnoreInvites;
            _allowPetSpeech        = PetsMuted;
            _allowBotSpeech        = BotsMuted;
            _allowPublicRoomStatus = HideInRoom;
            _allowConsoleMessages  = true;
            _allowGifts            = AllowGifts;
            _allowMimic            = AllowMimic;
            _receiveWhispers       = true;
            _ignorePublicWhispers  = false;
            _playingFastFood       = false;
            _friendbarState        = FriendBarStateUtility.GetEnum(FriendBarState);
            _christmasDay          = ChristmasDay;
            _wantsToRideHorse      = 0;
            _timeAFK = 0;
            _disableForcedEffects = DisableForcedEffects;
            _vipRank = VIPRank;

            _disconnected = false;
            _habboSaved   = false;
            _changingName = false;

            _floodTime   = 0;
            _friendCount = 0;
            _timeMuted   = TimeMuted;
            _timeCached  = DateTime.Now;

            _tradingLockExpiry = TradingLock;
            if (_tradingLockExpiry > 0 && PlusEnvironment.GetUnixTimestamp() > TradingLockExpiry)
            {
                _tradingLockExpiry = 0;
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `user_info` SET `trading_locked` = '0' WHERE `user_id` = '" + Id + "' LIMIT 1");
                }
            }

            _bannedPhraseCount  = 0;
            _sessionStart       = PlusEnvironment.GetUnixTimestamp();
            _messengerSpamCount = 0;
            _messengerSpamTime  = 0;
            _creditsTickUpdate  = Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("user.currency_scheduler.tick"));

            _tentId            = 0;
            _hopperId          = 0;
            _isHopping         = false;
            _teleportId        = 0;
            _isTeleporting     = false;
            _teleportingRoomId = 0;
            _roomAuthOk        = false;
            _currentRoomId     = 0;

            _hasSpoken                = false;
            _lastAdvertiseReport      = 0;
            _advertisingReported      = false;
            _advertisingReportBlocked = AdvertisingReportBlocked;

            _wiredInteraction   = false;
            _questLastCompleted = 0;
            _inventoryAlert     = false;
            _ignoreBobbaFilter  = false;
            _wiredTeleporting   = false;
            _customBubbleId     = 0;
            _onHelperDuty       = false;
            _fastfoodScore      = 0;
            _petId   = 0;
            _tempInt = 0;

            _lastGiftPurchaseTime       = DateTime.Now;
            _lastMottoUpdateTime        = DateTime.Now;
            _lastClothingUpdateTime     = DateTime.Now;
            _lastForumMessageUpdateTime = DateTime.Now;

            _giftPurchasingWarnings = 0;
            _mottoUpdateWarnings    = 0;
            _clothingUpdateWarnings = 0;

            _sessionGiftBlocked     = false;
            _sessionMottoBlocked    = false;
            _sessionClothingBlocked = false;

            FavoriteRooms = new ArrayList();
            Achievements  = new ConcurrentDictionary <string, UserAchievement>();
            Relationships = new Dictionary <int, Relationship>();
            RatedRooms    = new List <int>();

            //TODO: Nope.
            InitPermissions();

            #region Stats
            DataRow StatRow = null;
            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                dbClient.AddParameter("user_id", Id);
                StatRow = dbClient.GetRow();

                if (StatRow == null)//No row, add it yo
                {
                    dbClient.RunQuery("INSERT INTO `user_stats` (`id`) VALUES ('" + Id + "')");
                    dbClient.SetQuery("SELECT `id`,`roomvisits`,`onlinetime`,`respect`,`respectgiven`,`giftsgiven`,`giftsreceived`,`dailyrespectpoints`,`dailypetrespectpoints`,`achievementscore`,`quest_id`,`quest_progress`,`groupid`,`tickets_answered`,`respectstimestamp`,`forum_posts` FROM `user_stats` WHERE `id` = @user_id LIMIT 1");
                    dbClient.AddParameter("user_id", Id);
                    StatRow = dbClient.GetRow();
                }

                try
                {
                    _habboStats = new HabboStats(Convert.ToInt32(StatRow["roomvisits"]), Convert.ToDouble(StatRow["onlineTime"]), Convert.ToInt32(StatRow["respect"]), Convert.ToInt32(StatRow["respectGiven"]), Convert.ToInt32(StatRow["giftsGiven"]),
                                                 Convert.ToInt32(StatRow["giftsReceived"]), Convert.ToInt32(StatRow["dailyRespectPoints"]), Convert.ToInt32(StatRow["dailyPetRespectPoints"]), Convert.ToInt32(StatRow["AchievementScore"]),
                                                 Convert.ToInt32(StatRow["quest_id"]), Convert.ToInt32(StatRow["quest_progress"]), Convert.ToInt32(StatRow["groupid"]), Convert.ToString(StatRow["respectsTimestamp"]), Convert.ToInt32(StatRow["forum_posts"]));

                    if (Convert.ToString(StatRow["respectsTimestamp"]) != DateTime.Today.ToString("MM/dd"))
                    {
                        _habboStats.RespectsTimestamp = DateTime.Today.ToString("MM/dd");
                        SubscriptionData SubData = null;

                        int DailyRespects = 10;

                        if (_permissions.HasRight("mod_tool"))
                        {
                            DailyRespects = 20;
                        }
                        else if (PlusEnvironment.GetGame().GetSubscriptionManager().TryGetSubscriptionData(VIPRank, out SubData))
                        {
                            DailyRespects = SubData.Respects;
                        }

                        _habboStats.DailyRespectPoints    = DailyRespects;
                        _habboStats.DailyPetRespectPoints = DailyRespects;

                        dbClient.RunQuery("UPDATE `user_stats` SET `dailyRespectPoints` = '" + DailyRespects + "', `dailyPetRespectPoints` = '" + DailyRespects + "', `respectsTimestamp` = '" + DateTime.Today.ToString("MM/dd") + "' WHERE `id` = '" + Id + "' LIMIT 1");
                    }
                }
                catch (Exception e)
                {
                    ExceptionLogger.LogException(e);
                }
            }

            Group G = null;
            if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(_habboStats.FavouriteGroupId, out G))
            {
                _habboStats.FavouriteGroupId = 0;
            }
            #endregion
        }
Esempio n. 23
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = Session.GetHabbo().CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            string Message = StringCharFilter.Escape(Packet.PopString());

            if (Message.Length > 100)
            {
                Message = Message.Substring(0, 100);
            }

            int Colour = Packet.PopInt();

            ChatStyle Style = null;

            if (!PlusEnvironment.GetGame().GetChatManager().GetChatStyles().TryGetStyle(Colour, out Style) || (Style.RequiredRight.Length > 0 && !Session.GetHabbo().GetPermissions().HasRight(Style.RequiredRight)))
            {
                Colour = 0;
            }

            User.LastBubble = Session.GetHabbo().CustomBubbleId == 0 ? Colour : Session.GetHabbo().CustomBubbleId;

            if (PlusEnvironment.GetUnixTimestamp() < Session.GetHabbo().FloodTime&& Session.GetHabbo().FloodTime != 0)
            {
                return;
            }

            if (Session.GetHabbo().TimeMuted > 0)
            {
                Session.SendPacket(new MutedComposer(Session.GetHabbo().TimeMuted));
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("room_ignore_mute") && Room.CheckMute(Session))
            {
                Session.SendWhisper("Oops, you're currently muted.");
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                int MuteTime;
                if (User.IncrementAndCheckFlood(out MuteTime))
                {
                    Session.SendPacket(new FloodControlComposer(MuteTime));
                    return;
                }
            }

            PlusEnvironment.GetGame().GetChatManager().GetLogs().StoreChatlog(new ChatlogEntry(Session.GetHabbo().Id, Room.Id, Message, UnixTimestamp.GetNow(), Session.GetHabbo(), Room));

            if (Message.StartsWith(":", StringComparison.CurrentCulture) && PlusEnvironment.GetGame().GetChatManager().GetCommands().Parse(Session, Message))
            {
                return;
            }

            if (PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckBannedWords(Message))
            {
                Session.GetHabbo().BannedPhraseCount++;
                if (Session.GetHabbo().BannedPhraseCount >= (Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.chat.filter.banned_phrases.chances"))))
                {
                    PlusEnvironment.GetGame().GetModerationManager().BanUser("System", HabboHotel.Moderation.ModerationBanType.Username, Session.GetHabbo().Username, "Spamming banned phrases (" + Message + ")", (PlusEnvironment.GetUnixTimestamp() + 78892200));
                    Session.Disconnect();
                    return;
                }
                Session.SendPacket(new ShoutComposer(User.VirtualId, Message, 0, Colour));
                return;
            }

            if (!Session.GetHabbo().GetPermissions().HasRight("word_filter_override"))
            {
                Message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Message);
            }

            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.SocialChat);

            User.UnIdle();
            User.OnChat(User.LastBubble, Message, true);
        }
Esempio n. 24
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            int    pageId      = packet.PopInt();
            int    itemId      = packet.PopInt();
            string data        = packet.PopString();
            string giftUser    = StringCharFilter.Escape(packet.PopString());
            string giftMessage = StringCharFilter.Escape(packet.PopString().Replace(Convert.ToChar(5), ' '));
            int    spriteId    = packet.PopInt();
            int    ribbon      = packet.PopInt();
            int    colour      = packet.PopInt();

            packet.PopBoolean();

            if (PlusEnvironment.GetSettingsManager().TryGetValue("room.item.gifts.enabled") != "1")
            {
                session.SendNotification("The hotel managers have disabled gifting");
                return;
            }

            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 (!ItemUtility.CanGiftItem(item))
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetItemManager().GetGift(spriteId, out ItemData presentData) || presentData.InteractionType != InteractionType.GIFT)
            {
                return;
            }

            if (session.GetHabbo().Credits < item.CostCredits)
            {
                session.SendPacket(new PresentDeliverErrorMessageComposer(true, false));
                return;
            }

            if (session.GetHabbo().Duckets < item.CostPixels)
            {
                session.SendPacket(new PresentDeliverErrorMessageComposer(false, true));
                return;
            }

            Habbo habbo = PlusEnvironment.GetHabboByUsername(giftUser);

            if (habbo == null)
            {
                session.SendPacket(new GiftWrappingErrorComposer());
                return;
            }

            if (!habbo.AllowGifts)
            {
                session.SendNotification("Oops, this user doesn't allow gifts to be sent to them!");
                return;
            }

            if ((DateTime.Now - session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
            {
                session.SendNotification("You're purchasing gifts too fast! Please wait 15 seconds!");

                session.GetHabbo().GiftPurchasingWarnings += 1;
                if (session.GetHabbo().GiftPurchasingWarnings >= 25)
                {
                    session.GetHabbo().SessionGiftBlocked = true;
                }
                return;
            }

            if (session.GetHabbo().SessionGiftBlocked)
            {
                return;
            }


            string ed = giftUser + Convert.ToChar(5) + giftMessage + Convert.ToChar(5) + session.GetHabbo().Id + Convert.ToChar(5) + item.Data.Id + Convert.ToChar(5) + spriteId + Convert.ToChar(5) + ribbon + Convert.ToChar(5) + colour;

            int newItemId;

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                //Insert the dummy item.
                dbClient.SetQuery("INSERT INTO `items` (`base_item`,`user_id`,`extra_data`) VALUES (@baseId, @habboId, @extra_data)");
                dbClient.AddParameter("baseId", presentData.Id);
                dbClient.AddParameter("habboId", habbo.Id);
                dbClient.AddParameter("extra_data", ed);
                newItemId = Convert.ToInt32(dbClient.InsertQuery());

                string itemExtraData = null;
                switch (item.Data.InteractionType)
                {
                case InteractionType.NONE:
                    itemExtraData = "";
                    break;

                    #region Pet handling

                case InteractionType.PET:

                    try
                    {
                        string[] bits    = data.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
                    {
                        return;
                    }

                    break;

                    #endregion

                case InteractionType.FLOOR:
                case InteractionType.WALLPAPER:
                case InteractionType.LANDSCAPE:

                    double number = 0;
                    try
                    {
                        number = string.IsNullOrEmpty(data) ? 0 : double.Parse(data, PlusEnvironment.CultureInfo);
                    }
                    catch
                    {
                        //ignored
                    }

                    itemExtraData = number.ToString(CultureInfo.CurrentCulture).Replace(',', '.');
                    break;     // maintain extra data // todo: validate

                case InteractionType.POSTIT:
                    itemExtraData = "FFFF33";
                    break;

                case InteractionType.MOODLIGHT:
                    itemExtraData = "1,1,1,#000000,255";
                    break;

                case InteractionType.TROPHY:
                    itemExtraData = session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + data;
                    break;

                case InteractionType.MANNEQUIN:
                    itemExtraData = "m" + Convert.ToChar(5) + ".ch-210-1321.lg-285-92" + Convert.ToChar(5) + "Default Mannequin";
                    break;

                case InteractionType.BADGE_DISPLAY:
                    if (!session.GetHabbo().GetBadgeComponent().HasBadge(data))
                    {
                        session.SendPacket(new BroadcastMessageAlertComposer("Oops, it appears that you do not own this badge."));
                        return;
                    }

                    itemExtraData = data + Convert.ToChar(9) + session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;
                    break;

                default:
                    itemExtraData = data;
                    break;
                }

                //Insert the present, forever.
                dbClient.SetQuery("INSERT INTO `user_presents` (`item_id`,`base_id`,`extra_data`) VALUES (@itemId, @baseId, @extra_data)");
                dbClient.AddParameter("itemId", newItemId);
                dbClient.AddParameter("baseId", item.Data.Id);
                dbClient.AddParameter("extra_data", string.IsNullOrEmpty(itemExtraData) ? "" : itemExtraData);
                dbClient.RunQuery();

                //Here we're clearing up a record, this is dumb, but okay.
                dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @deleteId LIMIT 1");
                dbClient.AddParameter("deleteId", newItemId);
                dbClient.RunQuery();
            }


            Item giveItem = ItemFactory.CreateGiftItem(presentData, habbo, ed, ed, newItemId);
            if (giveItem != null)
            {
                GameClient receiver = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(habbo.Id);
                if (receiver != null)
                {
                    receiver.GetHabbo().GetInventoryComponent().TryAddItem(giveItem);
                    receiver.SendPacket(new FurniListNotificationComposer(giveItem.Id, 1));
                    receiver.SendPacket(new PurchaseOKComposer());
                    receiver.SendPacket(new FurniListAddComposer(giveItem));
                    receiver.SendPacket(new FurniListUpdateComposer());
                }

                if (habbo.Id != session.GetHabbo().Id&& !string.IsNullOrWhiteSpace(giftMessage))
                {
                    PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_GiftGiver", 1);
                    if (receiver != null)
                    {
                        PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(receiver, "ACH_GiftReceiver", 1);
                    }
                    PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.GiftOthers);
                }
            }

            session.SendPacket(new PurchaseOKComposer(item, presentData));

            if (item.CostCredits > 0)
            {
                session.GetHabbo().Credits -= item.CostCredits;
                session.SendPacket(new CreditBalanceComposer(session.GetHabbo().Credits));
            }

            if (item.CostPixels > 0)
            {
                session.GetHabbo().Duckets -= item.CostPixels;
                session.SendPacket(new HabboActivityPointNotificationComposer(session.GetHabbo().Duckets, session.GetHabbo().Duckets));
            }

            session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;
        }
Esempio n. 25
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.Habbo == null || !session.Habbo.InRoom)
            {
                return;
            }

            Room room = session.Habbo.CurrentRoom;

            if (room == null)
            {
                return;
            }

            RoomUser user = room.GetRoomUserManager().GetRoomUserByHabbo(session.Habbo.Id);

            if (user == null)
            {
                return;
            }

            string message = StringCharFilter.Escape(packet.PopString());

            if (message.Length > 100)
            {
                message = message.Substring(0, 100);
            }

            int colour = packet.PopInt();

            if (!PlusEnvironment.GetGame().GetChatManager().GetChatStyles().TryGetStyle(colour, out ChatStyle style) || style.RequiredRight.Length > 0 && !session.Habbo.GetPermissions().HasRight(style.RequiredRight))
            {
                colour = 0;
            }

            user.LastBubble = session.Habbo.CustomBubbleId == 0 ? colour : session.Habbo.CustomBubbleId;

            if (PlusEnvironment.GetUnixTimestamp() < session.Habbo.FloodTime && session.Habbo.FloodTime != 0)
            {
                return;
            }

            if (session.Habbo.TimeMuted > 0)
            {
                session.SendPacket(new MutedComposer(session.Habbo.TimeMuted));
                return;
            }

            if (!session.Habbo.GetPermissions().HasRight("room_ignore_mute") && room.CheckMute(session))
            {
                session.SendWhisper("Oops, you're currently muted.");
                return;
            }

            if (!session.Habbo.GetPermissions().HasRight("mod_tool"))
            {
                if (user.IncrementAndCheckFlood(out int muteTime))
                {
                    session.SendPacket(new FloodControlComposer(muteTime));
                    return;
                }
            }

            PlusEnvironment.GetGame().GetChatManager().GetLogs().StoreChatlog(new ChatlogEntry(session.Habbo.Id, room.Id, message, UnixTimestamp.GetNow(), session.Habbo, room));

            if (message.StartsWith(":", StringComparison.CurrentCulture) && PlusEnvironment.GetGame().GetChatManager().GetCommands().Parse(session, message))
            {
                return;
            }

            if (PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckBannedWords(message))
            {
                session.Habbo.BannedPhraseCount++;
                if (session.Habbo.BannedPhraseCount >= Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.chat.filter.banned_phrases.chances")))
                {
                    PlusEnvironment.GetGame().GetModerationManager().BanUser("System", HabboHotel.Moderation.ModerationBanType.Username, session.Habbo.Username, "Spamming banned phrases (" + message + ")", PlusEnvironment.GetUnixTimestamp() + 78892200);
                    session.Disconnect();
                    return;
                }
                session.SendPacket(new ShoutComposer(user.VirtualId, message, 0, colour));
                return;
            }

            if (!session.Habbo.GetPermissions().HasRight("word_filter_override"))
            {
                message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(message);
            }

            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.SocialChat);

            user.UnIdle();
            user.OnChat(user.LastBubble, message, true);
        }
Esempio n. 26
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("You must inculde a thing to update, e.g. :update catalog");
                return;
            }

            string UpdateVariable = Params[1];

            switch (UpdateVariable.ToLower())
            {
            case "cata":
            case "catalog":
            case "catalogue":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_catalog"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_catalog' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetCatalog().Init(PlusEnvironment.GetGame().GetItemManager());
                PlusEnvironment.GetGame().GetClientManager().SendPacket(new CatalogUpdatedComposer());
                Session.SendWhisper("Catalogue successfully updated.");
                break;
            }

            case "items":
            case "furni":
            case "furniture":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_furni"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_furni' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetItemManager().Init();
                Session.SendWhisper("Items successfully updated.");
                break;
            }

            case "models":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_models"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_models' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetRoomManager().LoadModels();
                Session.SendWhisper("Room models successfully updated.");
                break;
            }

            case "promotions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_promotions"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_promotions' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetLandingManager().Init();
                Session.SendWhisper("Landing view promotions successfully updated.");
                break;
            }

            case "youtube":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_youtube"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_youtube' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetTelevisionManager().Init();
                Session.SendWhisper("Youtube televisions playlist successfully updated.");
                break;
            }

            case "filter":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_filter"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_filter' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetFilter().Init();
                Session.SendWhisper("Filter definitions successfully updated.");
                break;
            }

            case "navigator":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_navigator"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_navigator' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetNavigator().Init();
                Session.SendWhisper("Navigator items successfully updated.");
                break;
            }

            case "ranks":
            case "rights":
            case "permissions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_rights"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_rights' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetPermissionManager().Init();

                foreach (GameClient Client in PlusEnvironment.GetGame().GetClientManager().GetClients.ToList())
                {
                    if (Client == null || Client.GetHabbo() == null || Client.GetHabbo().GetPermissions() == null)
                    {
                        continue;
                    }

                    Client.GetHabbo().GetPermissions().Init(Client.GetHabbo());
                }

                Session.SendWhisper("Rank definitions successfully updated.");
                break;
            }

            case "config":
            case "settings":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_configuration"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_configuration' permission.");
                    break;
                }

                PlusEnvironment.GetSettingsManager().Init();
                Session.SendWhisper("Server configuration successfully updated.");
                break;
            }

            case "bans":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_bans"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_bans' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetModerationManager().ReCacheBans();
                Session.SendWhisper("Ban cache re-loaded.");
                break;
            }

            case "quests":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_quests"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_quests' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetQuestManager().Init();
                Session.SendWhisper("Quest definitions successfully updated.");
                break;
            }

            case "achievements":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_achievements"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_achievements' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetAchievementManager().Init();
                Session.SendWhisper("Achievement definitions bans successfully updated.");
                break;
            }

            case "moderation":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_moderation"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_moderation' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetModerationManager().Init();
                PlusEnvironment.GetGame().GetClientManager().ModAlert("Moderation presets have been updated. Please reload the client to view the new presets.");

                Session.SendWhisper("Moderation configuration successfully updated.");
                break;
            }

            case "vouchers":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_vouchers"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_vouchers' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetCatalog().GetVoucherManager().Init();
                Session.SendWhisper("Catalogue vouche cache successfully updated.");
                break;
            }

            case "gc":
            case "games":
            case "gamecenter":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_game_center"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_game_center' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetGameDataManager().Init();
                Session.SendWhisper("Game Center cache successfully updated.");
                break;
            }

            case "pet_locale":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_pet_locale"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_pet_locale' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetPetLocale().Init();
                Session.SendWhisper("Pet locale cache successfully updated.");
                break;
            }

            case "locale":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_locale"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_locale' permission.");
                    break;
                }

                PlusEnvironment.GetLanguageManager().Init();
                Session.SendWhisper("Locale cache successfully updated.");
                break;
            }

            case "mutant":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_anti_mutant"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_anti_mutant' permission.");
                    break;
                }

                PlusEnvironment.GetFigureManager().Init();
                Session.SendWhisper("FigureData manager successfully reloaded.");
                break;
            }

            case "bots":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_bots"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_bots' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetBotManager().Init();
                Session.SendWhisper("Bot managaer successfully reloaded.");
                break;
            }

            case "rewards":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_rewards"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_rewards' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetRewardManager().Init();
                Session.SendWhisper("Rewards managaer successfully reloaded.");
                break;
            }

            case "chat_styles":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_chat_styles"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_chat_styles' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetChatManager().GetChatStyles().Init();
                Session.SendWhisper("Chat Styles successfully reloaded.");
                break;
            }

            case "badge_definitions":
            {
                if (!Session.GetHabbo().GetPermissions().HasCommand("command_update_badge_definitions"))
                {
                    Session.SendWhisper("Oops, you do not have the 'command_update_badge_definitions' permission.");
                    break;
                }

                PlusEnvironment.GetGame().GetBadgeManager().Init();
                Session.SendWhisper("Badge definitions successfully reloaded.");
                break;
            }

            default:
                Session.SendWhisper("'" + UpdateVariable + "' is not a valid thing to reload.");
                break;
            }
        }
Esempio n. 27
0
 public RoomPromotion(string name, string description, int categoryId)
 {
     this._name             = name;
     this._description      = description;
     this._timestampStarted = PlusEnvironment.GetUnixTimestamp();
     this._timestampExpires = (PlusEnvironment.GetUnixTimestamp()) + (Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.promotion.lifespan")) * 60);
     this._categoryId       = categoryId;
 }
Esempio n. 28
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            if ((Room.AllowPets == 0 && !Room.CheckRights(Session, true)) || !Room.CheckRights(Session, true))
            {
                Session.SendPacket(new RoomErrorNotifComposer(1));
                return;
            }

            if (Room.GetRoomUserManager().PetCount > Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.pets.placement_limit")))
            {
                Session.SendPacket(new RoomErrorNotifComposer(2));//5 = I have too many.
                return;
            }

            Pet Pet = null;

            if (!Session.GetHabbo().GetInventoryComponent().TryGetPet(Packet.PopInt(), out Pet))
            {
                return;
            }

            if (Pet == null)
            {
                return;
            }

            if (Pet.PlacedInRoom)
            {
                Session.SendNotification("This pet is already in the room?");
                return;
            }

            int X = Packet.PopInt();
            int Y = Packet.PopInt();

            if (!Room.GetGameMap().CanWalk(X, Y, false))
            {
                Session.SendPacket(new RoomErrorNotifComposer(4));
                return;
            }

            RoomUser OldPet = null;

            if (Room.GetRoomUserManager().TryGetPet(Pet.PetId, out OldPet))
            {
                Room.GetRoomUserManager().RemoveBot(OldPet.VirtualId, false);
            }

            Pet.X = X;
            Pet.Y = Y;

            Pet.PlacedInRoom = true;
            Pet.RoomId       = Room.RoomId;

            List <RandomSpeech> RndSpeechList = new List <RandomSpeech>();
            RoomBot             RoomBot       = new RoomBot(Pet.PetId, Pet.RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, X, Y, 0, 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0);

            if (RoomBot == null)
            {
                return;
            }

            Room.GetRoomUserManager().DeployBot(RoomBot, Pet);

            Pet.DBState = DatabaseUpdateState.NeedsUpdate;
            Room.GetRoomUserManager().UpdatePets();

            Pet ToRemove = null;

            if (!Session.GetHabbo().GetInventoryComponent().TryRemovePet(Pet.PetId, out ToRemove))
            {
                log.Error("Error whilst removing pet: " + ToRemove.PetId);
                return;
            }

            Session.SendPacket(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets()));
        }
Esempio n. 29
0
 public bool TryExecute(string[] parameters)
 {
     PlusEnvironment.GetSettingsManager().Init();
     return(true);
 }
Esempio n. 30
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (!session.GetHabbo().InRoom)
            {
                return;
            }

            Room room = session.GetHabbo().CurrentRoom;

            if (room == null)
            {
                return;
            }

            if (!session.GetHabbo().GetPermissions().HasRight("mod_tool") && room.CheckMute(session))
            {
                session.SendWhisper("Oops, you're currently muted.");
                return;
            }

            if (PlusEnvironment.GetUnixTimestamp() < session.GetHabbo().FloodTime&& session.GetHabbo().FloodTime != 0)
            {
                return;
            }

            string Params  = packet.PopString();
            string toUser  = Params.Split(' ')[0];
            string message = Params.Substring(toUser.Length + 1);
            int    colour  = packet.PopInt();

            RoomUser user = room.GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            if (user == null)
            {
                return;
            }

            RoomUser user2 = room.GetRoomUserManager().GetRoomUserByHabbo(toUser);

            if (user2 == null)
            {
                return;
            }

            if (session.GetHabbo().TimeMuted > 0)
            {
                session.SendPacket(new MutedComposer(session.GetHabbo().TimeMuted));
                return;
            }

            if (!session.GetHabbo().GetPermissions().HasRight("word_filter_override"))
            {
                message = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(message);
            }

            if (!PlusEnvironment.GetGame().GetChatManager().GetChatStyles().TryGetStyle(colour, out ChatStyle style) || style.RequiredRight.Length > 0 && !session.GetHabbo().GetPermissions().HasRight(style.RequiredRight))
            {
                colour = 0;
            }

            user.LastBubble = session.GetHabbo().CustomBubbleId == 0 ? colour : session.GetHabbo().CustomBubbleId;

            if (!session.GetHabbo().GetPermissions().HasRight("mod_tool"))
            {
                if (user.IncrementAndCheckFlood(out int muteTime))
                {
                    session.SendPacket(new FloodControlComposer(muteTime));
                    return;
                }
            }

            if (!user2.GetClient().GetHabbo().ReceiveWhispers&& !session.GetHabbo().GetPermissions().HasRight("room_whisper_override"))
            {
                session.SendWhisper("Oops, this user has their whispers disabled!");
                return;
            }

            PlusEnvironment.GetGame().GetChatManager().GetLogs().StoreChatlog(new ChatlogEntry(session.GetHabbo().Id, room.Id, "<Whisper to " + toUser + ">: " + message, UnixTimestamp.GetNow(), session.GetHabbo(), room));

            if (PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckBannedWords(message))
            {
                session.GetHabbo().BannedPhraseCount++;
                if (session.GetHabbo().BannedPhraseCount >= Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.chat.filter.banned_phrases.chances")))
                {
                    PlusEnvironment.GetGame().GetModerationManager().BanUser("System", HabboHotel.Moderation.ModerationBanType.Username, session.GetHabbo().Username, "Spamming banned phrases (" + message + ")", PlusEnvironment.GetUnixTimestamp() + 78892200);
                    session.Disconnect();
                    return;
                }
                session.SendPacket(new WhisperComposer(user.VirtualId, message, 0, user.LastBubble));
                return;
            }


            PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(session, QuestType.SocialChat);

            user.UnIdle();
            user.GetClient().SendPacket(new WhisperComposer(user.VirtualId, message, 0, user.LastBubble));

            if (!user2.IsBot && user2.UserId != user.UserId)
            {
                if (!user2.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(session.GetHabbo().Id))
                {
                    user2.GetClient().SendPacket(new WhisperComposer(user.VirtualId, message, 0, user.LastBubble));
                }
            }

            List <RoomUser> toNotify = room.GetRoomUserManager().GetRoomUserByRank(2);

            if (toNotify.Count > 0)
            {
                foreach (RoomUser notifiable in toNotify)
                {
                    if (notifiable != null && notifiable.HabboId != user2.HabboId && notifiable.HabboId != user.HabboId)
                    {
                        if (notifiable.GetClient() != null && notifiable.GetClient().GetHabbo() != null && !notifiable.GetClient().GetHabbo().IgnorePublicWhispers)
                        {
                            notifiable.GetClient().SendPacket(new WhisperComposer(user.VirtualId, "[Whisper to " + toUser + "] " + message, 0, user.LastBubble));
                        }
                    }
                }
            }
        }