Example #1
0
 public void Handle(GameClient Session, ClientMessage Event)
 {
     if (((Session != null) && (Session.GetHabbo() != null)) && (Session.GetHabbo().CurrentRoom != null))
     {
         Room currentRoom = Session.GetHabbo().CurrentRoom;
         if (currentRoom.CheckRights(Session, true))
         {
             RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();
             if (roomMusicController.PlaylistSize < roomMusicController.PlaylistCapacity)
             {
                 int      num  = Event.PopWiredInt32();
                 UserItem item = Session.GetHabbo().GetInventoryComponent().GetItemById((uint)num);
                 if ((item != null) && (item.method_1().InteractionType == "musicdisc"))
                 {
                     SongItem diskItem = new SongItem(item);
                     if (roomMusicController.AddDisk(diskItem) >= 0)
                     {
                         //diskItem.SaveToDatabase((int)currentRoom.Id); // <-- old
                         diskItem.SaveToDatabase((int)roomMusicController.LinkedItemId); // <-- new
                         Session.GetHabbo().GetInventoryComponent().method_12((uint)num, 0u, true);
                         Session.GetHabbo().GetInventoryComponent().method_9(true);
                         Session.SendMessage(JukeboxDiscksComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>()));
                     }
                 }
             }
         }
     }
 }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

            if (Instance == null || Instance.GetRoomMusicManager().PlaylistSize >= MusicManager.PlaylistCapacity)
            {
                return;
            }

            int Itemid = Packet.PopInt();

            Item DiskItem = Session.GetHabbo().GetInventoryComponent().GetItem(Itemid);

            if (DiskItem == null || DiskItem.GetBaseItem().InteractionType != InteractionType.MUSIC_DISC)
            {
                return;
            }

            SongItem SongItem = new SongItem(DiskItem);

            if (Instance.GetRoomMusicManager().AddDisk(SongItem) >= 0)
            {
                SongItem.SaveToDatabase(Instance.RoomId);
                Session.GetHabbo().GetInventoryComponent().RemoveItem(DiskItem.Id);

                List <SongInstance> list = Instance.GetRoomMusicManager().Playlist.Values.ToList();

                Session.SendMessage(new GetJukeboxPlaylistsComposer(MusicManager.PlaylistCapacity, list));
                Session.SendMessage(new GetJukeboxDisksComposer(Session.GetHabbo().GetInventoryComponent().songDisks));

                list.Clear();
                list = null;
            }
        }
Example #3
0
        /// <summary>
        ///     Adds the playlist item.
        /// </summary>
        internal void AddPlaylistItem()
        {
            if (Session?.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            Room currentRoom = Session.GetHabbo().CurrentRoom;

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

            SoundMachineManager roomMusicController = currentRoom.GetRoomMusicController();

            if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity)
            {
                return;
            }

            uint num = Request.GetUInteger();

            UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(num);

            if (item == null || item.BaseItem.InteractionType != Interaction.MusicDisc)
            {
                return;
            }

            SongItem songItem = new SongItem(item);

            int num2 = roomMusicController.AddDisk(songItem);

            if (num2 < 0)
            {
                return;
            }

            songItem.SaveToDatabase(currentRoom.RoomId);

            Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true);

            using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                commitableQueryReactor.RunFastQuery($"UPDATE items_rooms SET user_id='0' WHERE id={num} LIMIT 1");

            Session.SendMessage(SoundMachineComposer.Compose(roomMusicController.PlaylistCapacity,
                                                             roomMusicController.Playlist.Values.ToList()));
        }
Example #4
0
        internal void AddPlaylistItem()
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            Room currentRoom = Session.GetHabbo().CurrentRoom;

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

            RoomMusicController musicController = currentRoom.GetRoomMusicController();


            if (musicController.PlaylistSize >= musicController.PlaylistCapacity)
            {
                return;
            }

            uint     itemID = Request.ReadUInt32();
            UserItem item   = Session.GetHabbo().GetInventoryComponent().GetItem(itemID);

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

            //RoomItem roomItem = new RoomItem(item.Id, currentRoom.RoomId, item.BaseItem, ((StringData)item.data).Data, 0, 0, 0, 0, currentRoom);
            SongItem sitem = new SongItem(item);

            int NewOrder = musicController.AddDisk(sitem);

            if (NewOrder < 0)
            {
                return;
            }
            sitem.SaveToDatabase(currentRoom.RoomId);
            Session.GetHabbo().GetInventoryComponent().RemoveItem(itemID, true);
            Session.SendMessage(JukeboxComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList()));
        }
Example #5
0
        public void AddNewCdToJuke()
        {
            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            var currentRoom = Session.GetHabbo().CurrentRoom;

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

            var musicController = currentRoom.GetRoomMusicController();

            if (musicController.PlaylistSize >= musicController.PlaylistCapacity)
            {
                return;
            }

            var itemId = Request.PopWiredInt32();
            var item   = Session.GetHabbo().GetInventoryComponent().GetItem((uint)itemId);

            if (item == null || item.mBaseItem.InteractionType != InteractionType.musicdisc)
            {
                return;
            }

            var sitem = new SongItem(item);

            var NewOrder = musicController.AddDisk(sitem);

            if (NewOrder < 0)
            {
                return;
            }

            sitem.SaveToDatabase((int)currentRoom.RoomId);
            Session.GetHabbo().GetInventoryComponent().RemoveItem((uint)itemId, true);
            Session.SendMessage(JukeboxDiscksComposer.SerializeSongInventory(Session.GetHabbo().GetInventoryComponent().songDisks));
            Session.SendMessage(JukeboxDiscksComposer.Compose(musicController.PlaylistCapacity, musicController.Playlist.Values.ToList()));
        }
Example #6
0
        /// <summary>
        /// Adds the playlist item.
        /// </summary>
        internal void AddPlaylistItem()
        {
            if (this.Session == null || this.Session.GetHabbo() == null || this.Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }
            Room currentRoom = this.Session.GetHabbo().CurrentRoom;

            if (!currentRoom.CheckRights(this.Session, true, false))
            {
                return;
            }
            RoomMusicController roomMusicController = currentRoom.GetRoomMusicController();

            if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity)
            {
                return;
            }
            uint     num  = this.Request.GetUInteger();
            UserItem item = this.Session.GetHabbo().GetInventoryComponent().GetItem(num);

            if (item == null || item.BaseItem.InteractionType != Interaction.MusicDisc)
            {
                return;
            }
            var songItem = new SongItem(item);
            int num2     = roomMusicController.AddDisk(songItem);

            if (num2 < 0)
            {
                return;
            }
            songItem.SaveToDatabase(currentRoom.RoomId);
            this.Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true);
            using (IQueryAdapter queryReactor = global::Plus.Plus.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Format("UPDATE items_rooms SET user_id='0' WHERE id={0} LIMIT 1", num));
            this.Session.SendMessage(JukeboxComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList <SongInstance>()));
        }
Example #7
0
        /// <summary>
        /// Adds the playlist item.
        /// </summary>
        internal void AddPlaylistItem()
        {
            if (Session?.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
                return;

            Room currentRoom = Session.GetHabbo().CurrentRoom;

            if (!currentRoom.CheckRights(Session, true))
                return;

            SoundMachineManager roomMusicController = currentRoom.GetRoomMusicController();

            if (roomMusicController.PlaylistSize >= roomMusicController.PlaylistCapacity)
                return;

            uint num = Request.GetUInteger();

            UserItem item = Session.GetHabbo().GetInventoryComponent().GetItem(num);

            if (item == null || item.BaseItem.InteractionType != Interaction.MusicDisc)
                return;

            var songItem = new SongItem(item);

            int num2 = roomMusicController.AddDisk(songItem);

            if (num2 < 0)
                return;

            songItem.SaveToDatabase(currentRoom.RoomId);

            Session.GetHabbo().GetInventoryComponent().RemoveItem(num, true);

            using (IQueryAdapter queryReactor = Azure.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery($"UPDATE items_rooms SET user_id='0' WHERE id={num} LIMIT 1");

            Session.SendMessage(SoundMachineComposer.Compose(roomMusicController.PlaylistCapacity, roomMusicController.Playlist.Values.ToList()));
        }
Example #8
0
        internal void LoadMusic()
        {
            DataTable table;
            DataTable table2;
            using (DatabaseClient @class = Essential.GetDatabase().GetClient())
            {
                table = @class.ReadDataTable("SELECT * FROM items_rooms_songs WHERE roomid = '" + Id + "'"); // <-- old
                table2 = @class.ReadDataTable("SELECT * FROM items_jukebox_songs WHERE jukeboxid = '" + this.GetRoomMusicController().LinkedItemId + "'"); // <-- new
            }

            foreach (DataRow row in table.Rows)
            {
                int songID = (int)row["songid"];
                uint num2 = (uint)row["itemid"];
                int baseItem = (int)row["baseitem"];
                SongItem diskItem = new SongItem((int)num2, songID, baseItem);
                diskItem.RemoveFromDatabase();
                diskItem.SaveToDatabase(this.GetRoomMusicController().LinkedItemId);
                this.GetRoomMusicController().AddDisk(diskItem);
            }

            foreach (DataRow row in table2.Rows)
            {
                int songID = (int)row["songid"];
                uint num2 = (uint)row["itemid"];
                int baseItem = (int)row["baseitem"];
                SongItem diskItem = new SongItem((int)num2, songID, baseItem);
                this.GetRoomMusicController().AddDisk(diskItem);
            }
        }