Esempio n. 1
0
        internal static void AlertUser(GameClient ModSession, uint UserId, String Message, Boolean Caution)
        {
            GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Caution && Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.caution.missingrank"));
                Caution = false;
            }

            Client.SendNotif(Message, Caution);

            if (Caution)
            {
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET cautions = cautions + 1 WHERE user_id = " + UserId + "");
                }
            }
        }
Esempio n. 2
0
        internal bool UserGotAuthorization(GameClient session)
        {
            foreach(string subs in clubsAllowed){
                if (session.GetHabbo().GetSubscriptionManager().HasSubscription(subs))
                    return true;
            }

            if (minrank == 0)
                return true;
            else if (minrank > 0)
            {
                if (minrank <= session.GetHabbo().Rank)
                    return true;
            }
            else if (minrank < 0)
            {
                if (minrank == -1)
                {
                    if (session.GetHabbo().CurrentRoom.CheckRights(session, false))
                        return true;
                }
                else if (minrank == -2)
                {
                    if (session.GetHabbo().CurrentRoom.CheckRights(session, true))
                        return true;
                }
            }

            return false;
        }
Esempio n. 3
0
        internal static void GivePixels(GameClient Client, int amount)
        {
            Double Timestamp = PiciEnvironment.GetUnixTimestamp();

            Client.GetHabbo().LastActivityPointsUpdate = Timestamp;
            Client.GetHabbo().ActivityPoints += amount;
            Client.GetHabbo().UpdateActivityPointsBalance(0);
        }
Esempio n. 4
0
        internal static ChatMessage CreateMessage(string message, GameClient user, Room room)
        {
            uint userID = user.GetHabbo().Id;
            string username = user.GetHabbo().Username;
            uint roomID = room.RoomId;
            string roomName = room.Name;
            bool isPublic = room.IsPublic;
            DateTime timeSpoken = DateTime.Now;

            ChatMessage chatMessage = new ChatMessage(userID, username, roomID, roomName, isPublic, message, timeSpoken);
            return chatMessage;
        }
        internal static ServerMessage Compose(GameClient Session, List<Achievement> Achievements)
        {
            ServerMessage Message = new ServerMessage(436); //436
            Message.AppendInt32(Achievements.Count);

            foreach (Achievement Achievement in Achievements)
            {
                UserAchievement UserData = Session.GetHabbo().GetAchievementData(Achievement.GroupName);
                int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);
                int TotalLevels = Achievement.Levels.Count;

                if (TargetLevel > TotalLevels)
                {
                    TargetLevel = TotalLevels;
                }

                AchievementLevel TargetLevelData = Achievement.Levels[TargetLevel];

                Message.AppendUInt(Achievement.Id);                                                           // Unknown (ID?)
                Message.AppendInt32(TargetLevel);                                                   // Target level
                Message.AppendStringWithBreak(Achievement.GroupName + TargetLevel);                 // Target name/desc/badge
                Message.AppendInt32(TargetLevelData.Requirement);                                   // Progress req/target
                Message.AppendInt32(TargetLevelData.RewardPixels);                                   // Pixel reward
                Message.AppendInt32(TargetLevelData.RewardPoints);                                  // Unknown(??)
                Message.AppendInt32(UserData != null ? UserData.Progress : 0);                      // Current progress
                Message.AppendBoolean(UserData != null ? (UserData.Level >= TotalLevels) : false);  // Set 100% completed(??)
                Message.AppendStringWithBreak(Achievement.Category);                                // Category
                Message.AppendInt32(TotalLevels);                                                   // Total amount of levels
            }

            return Message;
        }
Esempio n. 6
0
        private static void AddToPlaylist(GameClient Session, ClientMessage Message)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

            if (Instance == null || !Instance.CheckRights(Session, true) || !Instance.GotMusicController() ||
                Instance.GetRoomMusicController().PlaylistSize >= Instance.GetRoomMusicController().PlaylistCapacity)
            {
                return;
            }

            UserItem DiskUserItem = Session.GetHabbo().GetInventoryComponent().GetItem(Message.PopWiredUInt());

            if (DiskUserItem == null || DiskUserItem.GetBaseItem().InteractionType != InteractionType.musicdisc)
            {
                return;
            }

            SongItem item = new SongItem(DiskUserItem);

            int NewOrder = Instance.GetRoomMusicController().AddDisk(item);

            if (NewOrder < 0)
            {
                return;
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(item.itemID, true);

            Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity,
                Instance.GetRoomMusicController().Playlist.Values.ToList()));
        }
Esempio n. 7
0
        internal ServerMessage Serialize(GameClient Session)
        {
            ServerMessage Message = new ServerMessage(370);
            Message.AppendStringWithBreak(Session.GetHabbo().Id + "");
            Message.AppendStringWithBreak(Session.GetHabbo().Username);
            Message.AppendStringWithBreak(RoomId + "");
            Message.AppendInt32(Category);
            Message.AppendStringWithBreak(Name);
            Message.AppendStringWithBreak(Description);
            Message.AppendStringWithBreak(StartTime);
            Message.AppendInt32(Tags.Count);

            foreach (string Tag in Tags.ToArray())
            {
                Message.AppendStringWithBreak(Tag);
            }
            return Message;
        }
Esempio n. 8
0
        internal static Boolean NeedsUpdate(GameClient Client)
        {
            try
            {
                if (Client.GetHabbo() == null)
                    return false;

                Double PassedMins = (PiciEnvironment.GetUnixTimestamp() - Client.GetHabbo().LastActivityPointsUpdate) / 60;

                if (PassedMins >= RCV_EVERY_MINS)
                    return true;
            }
            catch (Exception e)
            {
                Logging.HandleException(e, "PixelManager.NeedsUpdate");
            }
            return false;
        }
Esempio n. 9
0
        internal static void BanUser(GameClient ModSession, uint UserId, int Length, String Message)
        {
            GameClient Client = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client == null || Client.GetHabbo().Id == ModSession.GetHabbo().Id)
            {
                return;
            }

            if (Client.GetHabbo().Rank >= ModSession.GetHabbo().Rank)
            {
                ModSession.SendNotif(LanguageLocale.GetValue("moderation.ban.missingrank"));
                return;
            }

            Double dLength = Length;

            PiciEnvironment.GetGame().GetBanManager().BanUser(Client, ModSession.GetHabbo().Username, dLength, Message, false);
        }
Esempio n. 10
0
        internal static void TryRedeemVoucher(GameClient Session, string Code)
        {
            if (!IsValidCode(Code))
            {
                ServerMessage Error = new ServerMessage(213);
                Error.AppendRawInt32(1);
                Session.SendMessage(Error);
                return;
            }

            int Value = GetVoucherValue(Code);

            TryDeleteVoucher(Code);

            Session.GetHabbo().Credits += Value;
            Session.GetHabbo().UpdateCreditsBalance();

            Session.SendMessage(new ServerMessage(212));
        }
Esempio n. 11
0
        internal static void SellItem(GameClient Session, uint ItemId, int SellingPrice)
        {
            UserItem Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
            {
                Session.GetMessageHandler().GetResponse().Init(610);
                Session.GetMessageHandler().GetResponse().AppendBoolean(false);
                Session.GetMessageHandler().GetResponse();
                Session.GetMessageHandler().SendResponse();
                return;
            }

            int Comission = CalculateComissionPrice(SellingPrice);
            int TotalPrice = SellingPrice + Comission;
            int ItemType = 1;

            if (Item.GetBaseItem().Type == 'i')
                ItemType++;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == DatabaseType.MSSQL)
                    dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data,state) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + Item.GetBaseItem().SpriteId + "," + ItemType + "," + PiciEnvironment.GetUnixTimestamp() + ",@extra_data, '1')");
                else
                    dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,sprite_id,item_type,timestamp,extra_data) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + Item.GetBaseItem().SpriteId + "," + ItemType + "," + PiciEnvironment.GetUnixTimestamp() + ",@extra_data)");
                dbClient.addParameter("public_name", Item.GetBaseItem().PublicName);
                dbClient.addParameter("extra_data", Item.ExtraData);
                dbClient.runQuery();
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId, false);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            Session.GetMessageHandler().GetResponse().Init(610);
            Session.GetMessageHandler().GetResponse().AppendBoolean(true);
            Session.GetMessageHandler().SendResponse();
        }
Esempio n. 12
0
        internal void ActivateQuest(GameClient Session, ClientMessage Message)
        {
            Quest Quest = GetQuest(Message.PopWiredUInt());

            if (Quest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                    dbClient.runFastQuery("REPLACE INTO user_quests VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ", 0)");
                else
                    dbClient.runFastQuery("IF NOT EXISTS (SELECT user_id FROM user_quests WHERE user_id = " + Session.GetHabbo().Id + " AND quest_id = " + Quest.Id + ") " +
                                          "INSERT INTO user_quests VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ", 0)");
                dbClient.runFastQuery("UPDATE users SET currentquestid = " + Quest.Id + " WHERE id = " + Session.GetHabbo().Id);
            }

            Session.GetHabbo().CurrentQuestId = Quest.Id;
            GetList(Session, null);
            Session.SendMessage(QuestStartedComposer.Compose(Session, Quest));
        }
Esempio n. 13
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Session == null)
                return;
            RoomUser interactingUser = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            Point userCoord = interactingUser.Coordinate;
            Point ballCoord = Item.Coordinate;

            int differenceX = userCoord.X - ballCoord.X;
            int differenceY = userCoord.Y - ballCoord.Y;

            if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1)
            {
                differenceX = differenceX * 2;
                differenceY = differenceY * 2;

                int newX = Item.GetX + differenceX;
                int newY = Item.GetY + differenceY;

                Item.GetRoom().GetSoccer().MoveBall(Item, Session, newX, newY);
                interactingUser.MoveTo(ballCoord);
            }
            else //if (differenceX == 2 || differenceY == 2 || differenceY == - 2 || differenceX == -2)
            {
                Item.interactingBallUser = Session.GetHabbo().Id;

                differenceX = differenceX * (-1);
                differenceY = differenceY * (-1);

                if (differenceX > 1)
                    differenceX = 1;
                else if (differenceX < -1)
                    differenceX = -1;

                if (differenceY > 1)
                    differenceY = 1;
                else if (differenceY < -1)
                    differenceY = -1;

                int newX = Item.GetX + differenceX;
                int newY = Item.GetY + differenceY;

                interactingUser.MoveTo(new Point(newX, newY));
            }
        }
Esempio n. 14
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Session != null)
                return;
            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            Point ItemCoordx1 = new Point(Item.Coordinate.X + 1, Item.Coordinate.Y);
            Point ItemCoordx2 = new Point(Item.Coordinate.X - 1, Item.Coordinate.Y);
            Point ItemCoordy1 = new Point(Item.Coordinate.X, Item.Coordinate.Y + 1);
            Point ItemCoordy2 = new Point(Item.Coordinate.X, Item.Coordinate.Y - 1);

            if (User == null)
            {
                return;
            }

            if (User.Coordinate != ItemCoordx1 && User.Coordinate != ItemCoordx2 && User.Coordinate != ItemCoordy1 && User.Coordinate != ItemCoordy2)
            {
                if (User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                    return;
                }
            }
            else
            {
                int NewX = Item.Coordinate.X;
                int NewY = Item.Coordinate.Y;

                if (User.Coordinate == ItemCoordx1)
                {
                    NewX = Item.Coordinate.X - 1;
                    NewY = Item.Coordinate.Y;
                }
                else if (User.Coordinate == ItemCoordx2)
                {
                    NewX = Item.Coordinate.X + 1;
                    NewY = Item.Coordinate.Y;
                }
                else if (User.Coordinate == ItemCoordy1)
                {
                    NewX = Item.Coordinate.X;
                    NewY = Item.Coordinate.Y - 1;
                }
                else if (User.Coordinate == ItemCoordy2)
                {
                    NewX = Item.Coordinate.X;
                    NewY = Item.Coordinate.Y + 1;
                }

                if (Item.GetRoom().GetGameMap().ValidTile(NewX, NewY))
                {
                    Double NewZ = Item.GetRoom().GetGameMap().SqAbsoluteHeight(NewX, NewY);

                    ServerMessage Message = new ServerMessage(230);
                    Message.AppendInt32(Item.Coordinate.X);
                    Message.AppendInt32(Item.Coordinate.Y);
                    Message.AppendInt32(NewX);
                    Message.AppendInt32(NewY);
                    Message.AppendInt32(1);
                    Message.AppendUInt(Item.Id);
                    Message.AppendByte(2);
                    Message.AppendStringWithBreak(TextHandling.GetString(NewZ));
                    Message.AppendString("M");
                    Item.GetRoom().SendMessage(Message);

                    Item.GetRoom().GetRoomItemHandler().SetFloorItem(User.GetClient(), Item, NewX, NewY, Item.Rot, false, false, true);
                }
            }
        }
Esempio n. 15
0
        internal RoomData CreateRoom(GameClient Session, string Name, string Model)
        {
            Name = PiciEnvironment.FilterInjectionChars(Name);

            if (!roomModels.ContainsKey(Model))
            {
                Session.SendNotif(LanguageLocale.GetValue("room.modelmissing"));
                return null;
            }

            Console.WriteLine("ClubOnly: " + ((RoomModel)roomModels[Model]).ClubOnly + "");

            if (((RoomModel)roomModels[Model]).ClubOnly == 1 && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
            {
                Session.SendNotif(LanguageLocale.GetValue("room.missingclub"));
                return null;
            }

            if (Name.Length < 3)
            {
                Session.SendNotif(LanguageLocale.GetValue("room.namelengthshort"));
                return null;
            }

            UInt32 RoomId = 0;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == DatabaseType.MSSQL)//description,public_ccts,tags,password
                    dbClient.setQuery("INSERT INTO rooms (roomtype,caption,owner,model_name,description,public_ccts,tags,password) OUTPUT INSERTED.* VALUES ('private',@caption,@username,@model,'','','','')");
                else
                    dbClient.setQuery("INSERT INTO rooms (roomtype,caption,owner,model_name) VALUES ('private',@caption,@username,@model)");
                dbClient.addParameter("caption", Name);
                dbClient.addParameter("model", Model);
                dbClient.addParameter("username", Session.GetHabbo().Username);

                RoomId = (UInt32)dbClient.insertQuery();

            }

            RoomData newRoomData = GenerateRoomData(RoomId);
            Session.GetHabbo().UsersRooms.Add(newRoomData);

            return newRoomData;
        }
Esempio n. 16
0
        internal static void SerializeQuest(ServerMessage Message, GameClient Session, Quest Quest, string Category)
        {
            int AmountInCat = PiciEnvironment.GetGame().GetQuestManager().GetAmountOfQuestsInCategory(Category);
            int Number = Quest == null ? AmountInCat : Quest.Number - 1;
            int UserProgress = Quest == null ? 0 : Session.GetHabbo().GetQuestProgress(Quest.Id);

            if (Quest != null && Quest.IsCompleted(UserProgress))
            {
                Number++;
            }

            Message.AppendStringWithBreak(Category);
            Message.AppendInt32(Number); // Quest progress in this cat
            Message.AppendInt32(AmountInCat); // Total quests in this cat
            Message.AppendInt32((int)QuestRewardType.Pixels); // Reward type (1 = Snowflakes, 2 = Love hearts, 3 = Pixels, 4 = Seashells, everything else is pixels
            Message.AppendUInt(Quest == null ? 0 : Quest.Id); // Quest id
            Message.AppendBoolean(Quest == null ? false : Session.GetHabbo().CurrentQuestId == Quest.Id); // Quest started
            Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.ActionName);
            Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.DataBit);
            Message.AppendInt32(Quest == null ? 0 : Quest.Reward);
            Message.AppendStringWithBreak(Quest == null ? string.Empty : Quest.Name);
            Message.AppendInt32(UserProgress); // Current progress
            Message.AppendUInt(Quest == null ? 0 : Quest.GoalData); // Target progress
            Message.AppendInt32(0); // "Next quest available countdown" in seconds
        }
Esempio n. 17
0
        internal static ServerMessage Compose(GameClient Session, List<Quest> Quests, bool Send)
        {
            Dictionary<string, int> UserQuestGoals = new Dictionary<string, int>();
            Dictionary<string, Quest> UserQuests = new Dictionary<string, Quest>();

            foreach (Quest Quest in Quests)
            {
                if (!UserQuestGoals.ContainsKey(Quest.Category))
                {
                    UserQuestGoals.Add(Quest.Category, 1);
                    UserQuests.Add(Quest.Category, null);
                }

                if (Quest.Number >= UserQuestGoals[Quest.Category])
                {
                    int UserProgress = Session.GetHabbo().GetQuestProgress(Quest.Id);

                    if (Session.GetHabbo().CurrentQuestId != Quest.Id && UserProgress >= Quest.GoalData)
                    {
                        UserQuestGoals[Quest.Category] = Quest.Number + 1;
                    }
                }
            }

            foreach (Quest Quest in Quests)
            {
                foreach (KeyValuePair<string, int> Goal in UserQuestGoals)
                {
                    if (Quest.Category == Goal.Key && Quest.Number == Goal.Value)
                    {
                        UserQuests[Goal.Key] = Quest;
                        break;
                    }
                }
            }

            ServerMessage Message = new ServerMessage(800);
            Message.AppendInt32(UserQuests.Count);

            // Active ones first
            foreach (KeyValuePair<string, Quest> UserQuest in UserQuests)
            {
                if (UserQuest.Value == null)
                {
                    continue;
                }

                SerializeQuest(Message, Session, UserQuest.Value, UserQuest.Key);
            }

            // Dead ones last
            foreach (KeyValuePair<string, Quest> UserQuest in UserQuests)
            {
                if (UserQuest.Value != null)
                {
                    continue;
                }

                SerializeQuest(Message, Session, UserQuest.Value, UserQuest.Key);
            }

            Message.AppendBoolean(Send);
            return Message;
        }
Esempio n. 18
0
        // PENDING REWRITE
        internal void BanUser(GameClient Client, string Moderator, Double LengthSeconds, string Reason, Boolean IpBan)
        {
            ModerationBanType Type = ModerationBanType.USERNAME;
            string Var = Client.GetHabbo().Username;
            string RawVar = "user";
            Double Expire = PiciEnvironment.GetUnixTimestamp() + LengthSeconds;

            if (Reason == null)
            {
                Client.SendNotif("Please fill in a reason to ban a user.");
                return;
            }

            if (IpBan)
            {
                Type = ModerationBanType.IP;
                Var = Client.GetConnection().getIp();
                RawVar = "ip";
            }

            ModerationBan ban = new ModerationBan(Type, Var, Reason, Expire);

            if (ban.Type == ModerationBanType.IP)
            {
                if (bannedIPs.ContainsKey(Var))
                    bannedIPs[Var] = ban;
                else
                    bannedIPs.Add(Var, ban);
            }
            else
            {
                if (bannedUsernames.ContainsKey(Var))
                    bannedUsernames[Var] = ban;
                else
                    bannedUsernames.Add(Var, ban);
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,'" + Expire + "',@mod,'" + DateTime.Now.ToLongDateString() + "')");
                dbClient.addParameter("rawvar", RawVar);
                dbClient.addParameter("var", Var);
                dbClient.addParameter("reason", Reason);
                dbClient.addParameter("mod", Moderator);
                dbClient.runQuery();
            }

            if (IpBan)
            {
                DataTable UsersAffected = null;

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id FROM users WHERE ip_last = @var");
                    dbClient.addParameter("var", Var);
                    UsersAffected = dbClient.getTable();
                }

                if (UsersAffected != null)
                {
                    using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        foreach (DataRow Row in UsersAffected.Rows)
                        {
                            dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(Row["id"]));
                        }
                    }
                }

                BanUser(Client, Moderator, LengthSeconds, Reason, false);
            }
            else
            {
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id);
                }

                Client.SendBanMessage(LanguageLocale.GetValue("moderation.banned") + " " + Reason);
                Client.Disconnect();
            }
        }
Esempio n. 19
0
 internal void UpdateUser(GameClient client)
 {
     this.client = client;
     if (client != null && client.GetHabbo() != null)
         currentRoom = client.GetHabbo().CurrentRoom;
 }
Esempio n. 20
0
 internal static ServerMessage Compose(GameClient Session)
 {
     return Session.GetHabbo().GetInventoryComponent().SerializeMusicDiscs();
 }
Esempio n. 21
0
        internal void MoveBall(RoomItem item, GameClient mover, int newX, int newY)
        {
            if (item == null || mover == null)
                return;

            if (!room.GetGameMap().itemCanBePlacedHere(newX, newY))
                return;

            Point oldRoomCoord = item.Coordinate;
            bool itemIsOnGameItem = GameItemOverlaps(item);

            Double NewZ = room.GetGameMap().Model.SqFloorHeight[newX, newY];

            ServerMessage Message = new ServerMessage(95);
            Message.AppendUInt(item.Id);
            Message.AppendInt32(3508);
            Message.AppendInt32(item.Coordinate.X);
            Message.AppendInt32(item.Coordinate.Y);
            Message.AppendInt32(newX);
            Message.AppendInt32(newY);
            Message.AppendInt32(4);
            Message.AppendStringWithBreak(NewZ.ToString());
            Message.AppendStringWithBreak("H11");
            Message.AppendInt32(-1);
            Message.AppendInt32(0);
            room.SendMessage(Message);

            ServerMessage mMessage = new ServerMessage();
            mMessage.Init(230); // Cf
            mMessage.AppendInt32(item.Coordinate.X);
            mMessage.AppendInt32(item.Coordinate.Y);
            mMessage.AppendInt32(newX);
            mMessage.AppendInt32(newY);
            mMessage.AppendInt32(1);
            mMessage.AppendUInt(item.Id);
            mMessage.AppendStringWithBreak(item.GetZ.ToString().Replace(',', '.'));
            mMessage.AppendStringWithBreak(NewZ.ToString().Replace(',', '.'));
            mMessage.AppendInt32(0);
            room.SendMessage(mMessage);

            if (oldRoomCoord.X == newX && oldRoomCoord.Y == newY)
                return;

            room.GetRoomItemHandler().SetFloorItem(mover, item, newX, newY, item.Rot, false, false, false, false);

            if (!itemIsOnGameItem)
                HandleFootballGameItems(new Point(newX, newY), room.GetRoomUserManager().GetRoomUserByHabbo(mover.GetHabbo().Id));
        }
Esempio n. 22
0
        internal void RemoveUserFromRoom(GameClient Session, Boolean NotifyClient, Boolean NotifyKick)
        {
            try
            {
                if (Session == null)
                    return;

                if (Session.GetHabbo() == null)
                    return;

                Session.GetHabbo().GetAvatarEffectsInventoryComponent().OnRoomExit();

                if (NotifyClient)
                {
                    if (NotifyKick)
                    {
                        Session.GetMessageHandler().GetResponse().Init(33);
                        Session.GetMessageHandler().GetResponse().AppendInt32(4008);
                        Session.GetMessageHandler().SendResponse();
                    }

                    Session.GetMessageHandler().GetResponse().Init(18);
                    Session.GetMessageHandler().SendResponse();
                }

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

                if (User != null)
                {
                    RemoveRoomUser(User);

                    if (Session.GetHabbo() != null)
                    {
                        if (!User.IsSpectator)
                        {
                            if (User.CurrentItemEffect != ItemEffectType.None)
                            {
                                User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                            }
                            //UserMatrix[User.X, User.Y] = false;

                            if (Session.GetHabbo() != null)
                            {
                                if (room.HasActiveTrade(Session.GetHabbo().Id))
                                    room.TryStopTrade(Session.GetHabbo().Id);

                                if (Session.GetHabbo().Username == room.Owner)
                                {
                                    if (room.HasOngoingEvent)
                                    {
                                        room.Event = new RoomEvent(0, null, null, 0, new List<string>());

                                        ServerMessage Message = new ServerMessage(370);
                                        Message.AppendStringWithBreak("-1");
                                        room.SendMessage(Message);

                                        PiciEnvironment.GetGame().GetRoomManager().GetEventManager().QueueRemoveEvent(room.RoomData, room.Event.Category);
                                    }
                                }
                                Session.GetHabbo().CurrentRoomId = 0;

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

                            //DateTime Start = DateTime.Now;
                            //using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                            //{
                            //    //TimeSpan TimeUsed1 = DateTime.Now - Start;
                            //    //Logging.LogThreadException("Time used on sys part 2: " + TimeUsed1.Seconds + "s, " + TimeUsed1.Milliseconds + "ms", "");

                            //    //if (Session.GetHabbo() != null)
                            //    //    dbClient.runFastQuery("UPDATE user_roomvisits SET exit_timestamp = '" + PiciEnvironment.GetUnixTimestamp() + "' WHERE room_id = '" + this.Id + "' AND user_id = '" + Id + "' ORDER BY exit_timestamp DESC LIMIT 1");
                            //    //dbClient.runFastQuery("UPDATE rooms SET users_now = " + UsersNow + " WHERE id = " + Id);
                            //    //dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + RoomId + ", " + UsersNow + ")");
                            //    dbClient.runFastQuery("UPDATE room_active SET active_users = " + UsersNow);
                            //}
                        }
                    }

                    usersByUserID.Remove(User.userID);
                    if (Session.GetHabbo() != null)
                        usersByUsername.Remove(Session.GetHabbo().Username.ToLower());

                    User.Dispose();
                }

            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Error during removing user from room:" + e.ToString());
            }
        }
Esempio n. 23
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Session == null || Session.GetHabbo() == null || Item.InteractingUser > 0)
                return;

            string username = Session.GetHabbo().Username;
            RoomUser user = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(username);

            user.GoalX = Item.GetX;
            user.GoalY = Item.GetY;

            if (user.team != Team.none)
                user.throwBallAtGoal = true;

            //Console.WriteLine(Request.ToString());

            //int oldValue = 0;

            //if (!string.IsNullOrEmpty(Item.ExtraData))
            //{
            //    try
            //    {
            //        oldValue = int.Parse(Item.ExtraData);
            //    }
            //    catch { }
            //}
            //if (oldValue == 0)
            //    oldValue = 1000;
            //    //oldValue = 11000;
            //else
            //    oldValue = 0;

            //Item.ExtraData = oldValue.ToString();
            //Item.UpdateState();
        }
Esempio n. 24
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            RoomUser User = null;
            if (Session != null)
                User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Item.ExtraData != "-1")
                {
                    if (Request == -1)
                    {
                        Item.ExtraData = "0";
                        Item.UpdateState();
                    }
                    else
                    {
                        Item.ExtraData = "-1";
                        Item.UpdateState(false, true);
                        Item.ReqUpdate(4, true);
                    }
                }
            }
            else
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
Esempio n. 25
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Item.ExtraData != "1" && Item.GetBaseItem().VendingIds.Count >= 1 && Item.InteractingUser == 0 && Session != null)
            {
                RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User == null)
                {
                    return;
                }

                if (!Gamemap.TilesTouching(User.X, User.Y, Item.GetX, Item.GetY))
                {
                    User.MoveTo(Item.SquareInFront);
                    return;
                }

                Item.InteractingUser = Session.GetHabbo().Id;

                User.CanWalk = false;
                User.ClearMovement(true);
                User.SetRot(Rotation.Calculate(User.X, User.Y, Item.GetX, Item.GetY), false);

                Item.ReqUpdate(2, true);

                Item.ExtraData = "1";
                Item.UpdateState(false, true);
            }
        }
Esempio n. 26
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            // Is this user valid?
            if (Item == null || Item.GetRoom() == null || Session == null || Session.GetHabbo() == null)
                return;
            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            // Alright. But is this user in the right position?
            if (User.Coordinate == Item.Coordinate || User.Coordinate == Item.SquareInFront)
            {
                // Fine. But is this tele even free?
                if (Item.InteractingUser != 0)
                {
                    return;
                }

                //User.TeleDelay = -1;
                Item.InteractingUser = User.GetClient().GetHabbo().Id;
            }
            else if (User.CanWalk)
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
Esempio n. 27
0
        internal void AddUserToRoom(GameClient Session, bool Spectator)
        {
            RoomUser User = new RoomUser(Session.GetHabbo().Id, room.RoomId, primaryPrivateUserID++, room, Spectator);
            User.userID = Session.GetHabbo().Id;

            string username = Session.GetHabbo().Username;
            uint userID = User.userID;

            if (usersByUsername.ContainsKey(username.ToLower()))
                usersByUsername.Remove(username.ToLower());

            if (usersByUserID.ContainsKey(userID))
                usersByUserID.Remove(userID);

            usersByUsername.Add(Session.GetHabbo().Username.ToLower(), User);
            usersByUserID.Add(Session.GetHabbo().Id, User);

            int PersonalID = secondaryPrivateUserID++;
            User.InternalRoomID = PersonalID;
            Session.CurrentRoomUserID = PersonalID;

            Session.GetHabbo().CurrentRoomId = room.RoomId;
            UserList.Add(PersonalID, User);
        }
Esempio n. 28
0
        internal void DeliverItems(GameClient Session, Item Item, int Amount, String ExtraData, uint songID = 0)
        {
            switch (Item.Type.ToString())
            {
                case "i":
                case "s":
                    for (int i = 0; i < Amount; i++)
                    {
                        //uint GeneratedId = GenerateItemId();
                        switch (Item.InteractionType)
                        {
                            case InteractionType.pet0:

                                string[] PetData = ExtraData.Split('\n');

                                Pet GeneratedPet = CreatePet(Session.GetHabbo().Id, PetData[0], 0, PetData[1], PetData[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet1:

                                string[] PetData1 = ExtraData.Split('\n');

                                Pet GeneratedPet1 = CreatePet(Session.GetHabbo().Id, PetData1[0], 1, PetData1[1], PetData1[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet1);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet2:

                                string[] PetData5 = ExtraData.Split('\n');

                                Pet GeneratedPet5 = CreatePet(Session.GetHabbo().Id, PetData5[0], 2, PetData5[1], PetData5[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet5);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet3:

                                string[] PetData2 = ExtraData.Split('\n');

                                Pet GeneratedPet2 = CreatePet(Session.GetHabbo().Id, PetData2[0], 3, PetData2[1], PetData2[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet2);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet4:

                                string[] PetData3 = ExtraData.Split('\n');

                                Pet GeneratedPet3 = CreatePet(Session.GetHabbo().Id, PetData3[0], 4, PetData3[1], PetData3[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet3);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet5:

                                string[] PetData7 = ExtraData.Split('\n');

                                Pet GeneratedPet7 = CreatePet(Session.GetHabbo().Id, PetData7[0], 5, PetData7[1], PetData7[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet7);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet6:
                                string[] PetData4 = ExtraData.Split('\n');

                                Pet GeneratedPet4 = CreatePet(Session.GetHabbo().Id, PetData4[0], 6, PetData4[1], PetData4[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet4);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet7:

                                string[] PetData6 = ExtraData.Split('\n');

                                Pet GeneratedPet6 = CreatePet(Session.GetHabbo().Id, PetData6[0], 7, PetData6[1], PetData6[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet6);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet8:

                                string[] PetData8 = ExtraData.Split('\n');

                                Pet GeneratedPet8 = CreatePet(Session.GetHabbo().Id, PetData8[0], 8, PetData8[1], PetData8[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet8);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;

                            case InteractionType.pet9:

                                string[] PetData9 = ExtraData.Split('\n');

                                Pet GeneratedPet9 = CreatePet(Session.GetHabbo().Id, PetData9[0], 9, PetData9[1], PetData9[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet9);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.pet10:

                                string[] PetData10 = ExtraData.Split('\n');

                                Pet GeneratedPet10 = CreatePet(Session.GetHabbo().Id, PetData10[0], 10, PetData10[1], PetData10[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet10);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.pet11:

                                string[] PetData11 = ExtraData.Split('\n');

                                Pet GeneratedPet11 = CreatePet(Session.GetHabbo().Id, PetData11[0], 11, PetData11[1], PetData11[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet11);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.pet12:
                                string[] PetData12 = ExtraData.Split('\n');

                                Pet GeneratedPet12 = CreatePet(Session.GetHabbo().Id, PetData12[0], 12, PetData12[1], PetData12[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet12);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.pet14:
                                string[] PetData14 = ExtraData.Split('\n');

                                Pet GeneratedPet14 = CreatePet(Session.GetHabbo().Id, PetData14[0], 14, PetData14[1], PetData14[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet14);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.pet15:
                                string[] PetData15 = ExtraData.Split('\n');

                                Pet GeneratedPet15 = CreatePet(Session.GetHabbo().Id, PetData15[0], 15, PetData15[1], PetData15[2]);

                                Session.GetHabbo().GetInventoryComponent().AddPet(GeneratedPet15);
                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, 320, "0", true, false, 0);

                                break;
                            case InteractionType.teleport:

                                uint idOne = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, "0", true, false, 0).Id;
                                uint idTwo = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, "0", true, false, 0).Id;

                                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                                {
                                    dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idOne + "," + idTwo + ")");
                                    dbClient.runFastQuery("INSERT INTO items_tele_links (tele_one_id,tele_two_id) VALUES (" + idTwo + "," + idOne + ")");
                                }

                                break;

                            case InteractionType.dimmer:

                                uint id = Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, ExtraData, true, false, 0).Id;
                                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                                {
                                    dbClient.runFastQuery("INSERT INTO items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES (" + id + ",0,1,'#000000,255,0','#000000,255,0','#000000,255,0')");
                                }

                                break;

                            case InteractionType.musicdisc:
                                {
                                    Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, songID.ToString(), true, false, songID);
                                    break;
                                }

                            default:

                                Session.GetHabbo().GetInventoryComponent().AddNewItem(0, Item.ItemId, ExtraData, true, false, songID);
                                break;
                        }
                    }

                    Session.GetHabbo().GetInventoryComponent().UpdateItems(false);
                    break;

                case "e":

                    for (int i = 0; i < Amount; i++)
                    {
                        Session.GetHabbo().GetAvatarEffectsInventoryComponent().AddEffect(Item.SpriteId, 3600);
                    }

                    break;

                case "h":

                    for (int i = 0; i < Amount; i++)
                    {
                        Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_club", 2678400);
                    }

                    if (!Session.GetHabbo().GetBadgeComponent().HasBadge("HC1"))
                    {
                        Session.GetHabbo().GetBadgeComponent().GiveBadge("HC1", true);
                    }

                    Session.GetMessageHandler().GetResponse().Init(7);
                    Session.GetMessageHandler().GetResponse().AppendStringWithBreak("habbo_club");

                    if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                    {
                        Double Expire = Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_club").ExpireTime;
                        Double TimeLeft = Expire - PiciEnvironment.GetUnixTimestamp();
                        int TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
                        int MonthsLeft = TotalDaysLeft / 31;

                        if (MonthsLeft >= 1) MonthsLeft--;

                        Session.GetMessageHandler().GetResponse().AppendInt32(TotalDaysLeft - (MonthsLeft * 31));
                        Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                        Session.GetMessageHandler().GetResponse().AppendInt32(MonthsLeft);
                    }
                    else
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Session.GetMessageHandler().GetResponse().AppendInt32(0);
                        }
                    }

                    Session.GetMessageHandler().SendResponse();

                    //List<string> Rights = PiciEnvironment.GetGame().GetRoleManager().GetRightsForHabbo(Session.GetHabbo());

                    Session.GetMessageHandler().GetResponse().Init(2);
                    Session.GetMessageHandler().GetResponse().AppendInt32(2);

                    if (Session.GetHabbo().HasRight("acc_anyroomowner"))
                        Session.GetMessageHandler().GetResponse().AppendInt32(7);
                    else if (Session.GetHabbo().HasRight("acc_anyroomrights"))
                        Session.GetMessageHandler().GetResponse().AppendInt32(5);
                    else if (Session.GetHabbo().HasRight("acc_supporttool"))
                        Session.GetMessageHandler().GetResponse().AppendInt32(4);
                    else
                        Session.GetMessageHandler().GetResponse().AppendInt32(0);

                    Session.GetMessageHandler().SendResponse();
                    PiciEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_BasicClub", 1); //ACH_VipClub
                    break;

                default:

                    Session.SendNotif(LanguageLocale.GetValue("catalog.buyerror"));
                    break;
            }
        }
Esempio n. 29
0
        internal override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            if (Session == null)
                return;
            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (User.Coordinate != Item.SquareInFront && User.CanWalk)
            {
                User.MoveTo(Item.SquareInFront);
                return;
            }

            if (!Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, User.AllowOverride))
            {
                return;
            }

            if (Item.InteractingUser == 0)
            {
                Item.InteractingUser = User.HabboId;

                User.CanWalk = false;

                if (User.IsWalking && (User.GoalX != Item.SquareInFront.X || User.GoalY != Item.SquareInFront.Y))
                {
                    User.ClearMovement(true);
                }

                User.AllowOverride = true;
                User.MoveTo(Item.Coordinate);

                Item.ReqUpdate(4, true);
            }
        }
Esempio n. 30
0
        internal void HandleRowchase(GameClient Session, int PageId, uint ItemId, string ExtraData, Boolean IsGift, string GiftUser, string GiftMessage)
        {
            CatalogPage Page;

            if (!Pages.TryGetValue(PageId, out Page))
                return;

            if (Page == null || Page.ComingSoon || !Page.Enabled || !Page.Visible || Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
            {
                return;
            }
            if (Page.MinRank > Session.GetHabbo().Rank)
            {
                return;
            }
            CatalogItem Item = Page.GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            uint GiftUserId = 0;

            if (IsGift)
            {
                if (!Item.GetBaseItem().AllowGift)
                {
                    return;
                }

                DataRow dRow;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id FROM users WHERE username = @gift_user");
                    dbClient.addParameter("gift_user", GiftUser);

                    dRow = dbClient.getRow();
                }

                if (dRow == null)
                {
                    Session.GetMessageHandler().GetResponse().Init(76);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                    Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
                    Session.GetMessageHandler().SendResponse();

                    return;
                }

                GiftUserId = Convert.ToUInt32(dRow[0]);

                if (GiftUserId == 0)
                {
                    Session.GetMessageHandler().GetResponse().Init(76);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                    Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
                    Session.GetMessageHandler().SendResponse();

                    return;
                }
            }

            Boolean CreditsError = false;
            Boolean PixelError = false;

            if (Session.GetHabbo().Credits < Item.CreditsCost)
            {
                CreditsError = true;
            }

            if (Session.GetHabbo().ActivityPoints < Item.PixelsCost)
            {
                PixelError = true;
            }

            if (CreditsError || PixelError)
            {
                Session.GetMessageHandler().GetResponse().Init(68);
                Session.GetMessageHandler().GetResponse().AppendBoolean(CreditsError);
                Session.GetMessageHandler().GetResponse().AppendBoolean(PixelError);
                Session.GetMessageHandler().SendResponse();

                return;
            }

            if (IsGift && Item.GetBaseItem().Type == 'e')
            {
                Session.SendNotif(LanguageLocale.GetValue("catalog.gift.send.error"));
                return;
            }

            if (Item.CrystalCost > 0)
            {
                int userCrystals = 0;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT crystals FROM users WHERE id = " + Session.GetHabbo().Id);
                    userCrystals = dbClient.getInteger();
                }

                if (Item.CrystalCost > userCrystals)
                {
                    Session.SendNotif(LanguageLocale.GetValue("catalog.crystalerror") + Item.CrystalCost);
                    return;
                }

                userCrystals = userCrystals - Item.CrystalCost;

                Session.GetMessageHandler().GetResponse().Init(MessageComposerIds.ActivityPointsMessageComposer);
                Session.GetMessageHandler().GetResponse().AppendInt32(2);
                Session.GetMessageHandler().GetResponse().AppendInt32(4);
                Session.GetMessageHandler().GetResponse().AppendInt32(userCrystals);
                Session.GetMessageHandler().SendResponse();

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE users SET crystals = " + userCrystals + " WHERE id = " + Session.GetHabbo().Id);

                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.crystalsbought") + userCrystals);
            }

            if (Item.Name.Contains("HABBO_CLUB"))
            {
                #region Purchase Club!
                // PAYmQHABBO_CLUB_BASIC_1_MONTHSCHHISGZvGSBSE[mQHABBO_CLUB_VIP_1_MONTHQFHIISGZvGSBSEXnQHABBO_CLUB_VIP_3_MONTHSPOHIKQW[vGIPFZmQHABBO_CLUB_BASIC_3_MONTHSQKHHKQW[vGIPF
                int TypeOfClub = 0;
                Subscription Sub;
                if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip"))
                    Sub = Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_vip");
                else if (Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
                    Sub = Session.GetHabbo().GetSubscriptionManager().GetSubscription("habbo_club");
                else
                    Sub = null;

                if (Item.Name == "HABBO_CLUB_BASIC_1_MONTH")
                {
                    TypeOfClub = 1;
                }
                else if (Item.Name.Contains("HABBO_CLUB_BASIC_3"))
                {
                    TypeOfClub = 2;
                }
                else if (Item.Name == "HABBO_CLUB_VIP_1_MONTH")
                {
                    TypeOfClub = 3;
                }
                else if (Item.Name.Contains("HABBO_CLUB_VIP_3"))
                {
                    TypeOfClub = 4;
                }
                else if (Item.Name == "HABBO_CLUB_UPGRADE_1")
                {
                    TypeOfClub = 5;
                }
                else if (Item.Name == "HABBO_CLUB_UPGRADE_3")
                {
                    TypeOfClub = 6;
                }

                if (TypeOfClub == 1)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_club", (60 * 60 * 24 * 31));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(1);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }
                else if (TypeOfClub == 2)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_club", (60 * 60 * 24 * 31 * 3));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(1);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }
                else if (TypeOfClub == 3)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_vip", (60 * 60 * 24 * 31));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(2);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }
                else if (TypeOfClub == 4)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_vip", (60 * 60 * 24 * 31 * 3));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(2);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }
                else if (TypeOfClub == 5)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_vip", (60 * 60 * 24 * 31));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(2);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }
                else if (TypeOfClub == 6)
                {
                    Session.GetHabbo().GetSubscriptionManager().AddOrExtendSubscription("habbo_vip", (60 * 60 * 24 * 31 * 3));
                    ServerMessage FuseRight = new ServerMessage(2);
                    FuseRight.AppendInt32(2);
                    Session.SendMessage(FuseRight);
                    Session.GetMessageHandler().GetSubscriptionData();
                }

                bool CreditsFail = false;
                bool PixelsFail = false;

                if (Session.GetHabbo().Credits < Item.CreditsCost)
                {
                    CreditsFail = true;
                }

                if (CreditsFail || PixelsFail)
                {
                    ServerMessage Failed = new ServerMessage(68);
                    Failed.AppendBoolean(CreditsFail);
                    Failed.AppendBoolean(PixelsFail);
                    Session.SendMessage(Failed);
                    return;
                }

                if (Item.CreditsCost > 0)
                {
                    Session.GetHabbo().Credits -= Item.CreditsCost;
                    Session.GetHabbo().UpdateCreditsBalance();
                }

                ServerMessage PurchaseClub = new ServerMessage(67);
                //AC[mQHABBO_CLUB_VIP_1_MONTH{2}QFHHH{1}
                PurchaseClub.AppendUInt(Item.Id);
                PurchaseClub.AppendStringWithBreak(Item.Name);
                PurchaseClub.AppendInt32(Item.CreditsCost);
                PurchaseClub.AppendBoolean(true);
                PurchaseClub.AppendBoolean(false);
                PurchaseClub.AppendBoolean(false);
                Session.SendMessage(PurchaseClub);
                #endregion
                return;
            }

            if (Item.OudeCredits > 0)
            {
                int oudeCredits = 0;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT belcredits FROM users WHERE id = " + Session.GetHabbo().Id);
                    oudeCredits = dbClient.getInteger();
                }

                if (Item.OudeCredits > oudeCredits)
                {
                    Session.SendNotif(LanguageLocale.GetValue("catalog.oudebelcreditserror") + Item.OudeCredits);
                    return;
                }

                oudeCredits = oudeCredits - Item.OudeCredits;
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE users SET belcredits = " + oudeCredits + " WHERE id = " + Session.GetHabbo().Id);
                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.oudebelcreditsok") + oudeCredits);
            }

            //Console.WriteLine(Item.GetBaseItem().ItemId);
            //Console.WriteLine(Item.GetBaseItem().InteractionType.ToLower());
            // Extra Data is _NOT_ filtered at this point and MUST BE VERIFIED BELOW:
            switch (Item.GetBaseItem().InteractionType)
            {
                case InteractionType.none:
                    ExtraData = "";
                    break;

                case InteractionType.musicdisc:
                    ExtraData = Item.songID.ToString();
                    break;

                #region Pet handling
                case InteractionType.pet0:
                case InteractionType.pet1:
                case InteractionType.pet2:
                case InteractionType.pet3:
                case InteractionType.pet4:
                case InteractionType.pet5:
                case InteractionType.pet6:
                case InteractionType.pet7:
                case InteractionType.pet8:
                case InteractionType.pet9:
                case InteractionType.pet10:
                case InteractionType.pet11:
                case InteractionType.pet12:
                case InteractionType.pet14:
                case InteractionType.pet15:
                    try
                    {

                        //uint count = 0;
                        //using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                        //{
                        //    dbClient.setQuery("SELECT COUNT(*) FROM user_pets WHERE user_id = " + Session.GetHabbo().Id);
                        //    count = uint.Parse(dbClient.getString());
                        //}

                        //if (count > 5)
                        //{
                        //    Session.SendNotif(LanguageLocale.GetValue("catalog.pets.maxpets"));
                        //    return;
                        //}

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

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

                        if (!CheckPetName(PetName))
                            return;

                        if (Race.Length != 1)
                            return;

                        if (Color.Length != 6)
                            return;
                    }
                    catch (Exception e) {
                        //Logging.WriteLine(e.ToString());
                        Logging.HandleException(e, "Catalog.HandleRowchase");
                        return;
                    }

                    break;

                #endregion

                case InteractionType.roomeffect:

                    Double Number = 0;

                    try
                    {
                        if (string.IsNullOrEmpty(ExtraData))
                            Number = 0;
                        else
                            Number = Double.Parse(ExtraData, PiciEnvironment.cultureInfo);
                    }
                    catch (Exception e) { Logging.HandleException(e, "Catalog.HandleRowchase: " + ExtraData); }

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

                case InteractionType.postit:
                    ExtraData = "FFFF33";
                    break;

                case InteractionType.dimmer:
                    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) + PiciEnvironment.FilterInjectionChars(ExtraData, true);
                    break;

                default:
                    ExtraData = "";
                    break;
            }

            if (Item.CreditsCost > 0)
            {
                Session.GetHabbo().Credits -= Item.CreditsCost;
                Session.GetHabbo().UpdateCreditsBalance();
            }

            if (Item.PixelsCost > 0)
            {
                Session.GetHabbo().ActivityPoints -= Item.PixelsCost;
                Session.GetHabbo().UpdateActivityPointsBalance(true);
            }

            Session.GetMessageHandler().GetResponse().Init(101);
            Session.GetMessageHandler().SendResponse();

            Session.GetMessageHandler().GetResponse().Init(67);
            Session.GetMessageHandler().GetResponse().AppendUInt(Item.GetBaseItem().ItemId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.GetBaseItem().Name);
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.CreditsCost);
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.PixelsCost);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.GetBaseItem().Type.ToString().ToLower());
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.GetBaseItem().SpriteId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak("");
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().SendResponse();

            if (IsGift)
            {
                uint itemID;
                //uint GenId = GenerateItemId();
                Item Present = GeneratePresent();

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    if (dbClient.dbType == DatabaseType.MSSQL)
                        dbClient.setQuery("INSERT INTO items (base_id) OUTPUT INSERTED.* VALUES (" + Present.ItemId + ")");
                    else
                        dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + Present.ItemId + ")");
                    itemID = (uint)dbClient.insertQuery();

                    dbClient.runFastQuery("INSERT INTO items_users VALUES (" + itemID + "," + GiftUserId + ")");

                    if (!string.IsNullOrEmpty(GiftMessage))
                    {
                        dbClient.setQuery("INSERT INTO items_extradata VALUES (" + itemID + ",@data)");
                        dbClient.addParameter("data", GiftMessage);
                        dbClient.runQuery();
                    }

                    dbClient.setQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + itemID + "," + Item.GetBaseItem().ItemId + "," + Item.Amount + ",@extra_data)");
                    dbClient.addParameter("gift_message", "!" + GiftMessage);
                    dbClient.addParameter("extra_data", ExtraData);
                    dbClient.runQuery();
                }

                GameClient Receiver = PiciEnvironment.GetGame().GetClientManager().GetClientByUserID(GiftUserId);

                if (Receiver != null)
                {
                    Receiver.SendNotif(LanguageLocale.GetValue("catalog.gift.received") + Session.GetHabbo().Username);
                    Receiver.GetHabbo().GetInventoryComponent().AddNewItem(itemID, Present.ItemId, ExtraData, false, false, 0);
                    Receiver.GetHabbo().GetInventoryComponent().SendFloorInventoryUpdate();

                    InventoryComponent targetInventory = Receiver.GetHabbo().GetInventoryComponent();
                    if (targetInventory != null)
                        targetInventory.RunDBUpdate();
                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.gift.sent"));
            }
            else
            {
                DeliverItems(Session, Item.GetBaseItem(), Item.Amount, ExtraData, Item.songID);
            }
        }