Пример #1
0
        /// <summary>
        ///     Delivers the items.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="item">The item.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="extraData">The extra data.</param>
        /// <param name="limno">The limno.</param>
        /// <param name="limtot">The limtot.</param>
        /// <param name="songCode">The song code.</param>
        /// <returns>List&lt;UserItem&gt;.</returns>
        internal List <UserItem> DeliverItems(GameClient session, Item item, uint amount, string extraData, uint limno, uint limtot, string songCode)
        {
            List <UserItem> list = new List <UserItem>();

            if (item.InteractionType == Interaction.PostIt)
            {
                amount = amount * 20;
            }

            char a = item.Type;

            switch (a)
            {
            case 'i':
            case 's':
                int i = 0;

                while (i < amount)
                {
                    Interaction interactionType = item.InteractionType;

                    switch (interactionType)
                    {
                    case Interaction.Dimmer:
                        UserItem userItem33 = session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, 0, 0);
                        uint     id33       = userItem33.Id;

                        list.Add(userItem33);

                        using (IQueryAdapter queryreactor2 = Yupi.GetDatabaseManager().GetQueryReactor())
                            queryreactor2.RunFastQuery(
                                $"INSERT INTO items_moodlight (item_id,enabled,current_preset,preset_one,preset_two,preset_three) VALUES ({id33},'0',1,'#000000,255,0','#000000,255,0','#000000,255,0')");

                        break;

                    case Interaction.Trophy:
                    case Interaction.Bed:
                    case Interaction.PressurePadBed:
                    case Interaction.Guillotine:
                    case Interaction.ScoreBoard:
                    case Interaction.VendingMachine:
                    case Interaction.Alert:
                    case Interaction.OneWayGate:
                    case Interaction.LoveShuffler:
                    case Interaction.HabboWheel:
                    case Interaction.Dice:
                    case Interaction.Bottle:
                    case Interaction.Hopper:
                    case Interaction.Rentals:
                    case Interaction.Pet:
                    case Interaction.Pool:
                    case Interaction.Roller:
                    case Interaction.FootballGate:
                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, limno, limtot));
                        break;

                    case Interaction.Teleport:
                    case Interaction.QuickTeleport:
                        UserItem userItem  = session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, "0", 0u, true, false, 0, 0);
                        uint     id        = userItem.Id;
                        UserItem userItem2 = session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, "0", 0u, true, false, 0, 0);
                        uint     id2       = userItem2.Id;

                        list.Add(userItem);
                        list.Add(userItem2);

                        using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                            queryReactor.RunFastQuery($"INSERT INTO items_teleports (tele_one_id,tele_two_id) VALUES ('{id}','{id2}');" + $"INSERT INTO items_teleports (tele_one_id,tele_two_id) VALUES ('{id2}','{id}')");

                        break;

                    case Interaction.PetDog:
                    case Interaction.PetCat:
                    case Interaction.PetCrocodile:
                    case Interaction.PetTerrier:
                    case Interaction.PetBear:
                    case Interaction.PetPig:
                    case Interaction.PetLion:
                    case Interaction.PetRhino:
                    case Interaction.PetSpider:
                    case Interaction.PetTurtle:
                    case Interaction.PetChick:
                    case Interaction.PetFrog:
                    case Interaction.PetDragon:
                    case Interaction.PetHorse:
                    case Interaction.PetMonkey:
                    case Interaction.PetGnomo:
                    case Interaction.PetMonsterPlant:
                    case Interaction.PetWhiteRabbit:
                    case Interaction.PetEvilRabbit:
                    case Interaction.PetLoveRabbit:
                    case Interaction.PetPigeon:
                    case Interaction.PetEvilPigeon:
                    case Interaction.PetDemonMonkey:
                    case Interaction.Pet24:
                    case Interaction.Pet25:
                    case Interaction.Pet26:
                    case Interaction.Pet27:
                    case Interaction.Pet28:
                    case Interaction.Pet29:
                    case Interaction.Pet30:
                    case Interaction.Pet31:
                    case Interaction.Pet32:
                    case Interaction.Pet33:
                    case Interaction.Pet34:
                        string[] petData      = extraData.Split('\n');
                        int      petId        = int.Parse(item.Name.Replace("a0 pet", string.Empty));
                        Pet      generatedPet = CreatePet(session.GetHabbo().Id, petData[0], petId, petData[1],
                                                          petData[2]);

                        session.GetHabbo().GetInventoryComponent().AddPet(generatedPet);

                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0, item.Name, "0", 0u, true, false, 0, 0, string.Empty));
                        break;

                    case Interaction.MusicDisc:
                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, 0, 0, songCode));
                        break;

                    case Interaction.PuzzleBox:
                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, limno, limtot));
                        break;

                    case Interaction.RoomBg:
                        UserItem userItem44 = session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, 0, 0, string.Empty);
                        uint     id44       = userItem44.Id;

                        list.Add(userItem44);

                        using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor())
                            queryreactor3.RunFastQuery($"INSERT INTO items_toners VALUES ({id44},'0',0,0,0)");

                        break;

                    case Interaction.GuildItem:
                    case Interaction.GuildGate:
                    case Interaction.GroupForumTerminal:
                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, "0", Convert.ToUInt32(extraData), true, false, 0, 0, string.Empty));
                        break;

                    case Interaction.GuildForum:
                        uint groupId;

                        uint.TryParse(extraData, out groupId);

                        Group group = Yupi.GetGame().GetGroupManager().GetGroup(groupId);

                        if (group != null)
                        {
                            if (group.CreatorId == session.GetHabbo().Id)
                            {
                                group.UpdateForum(true);
                            }
                            else
                            {
                                session.SendNotif(Yupi.GetLanguage().GetVar("user_group_owner_error"));
                            }
                        }

                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, "0", Convert.ToUInt32(extraData), true, false, 0, 0, string.Empty));
                        break;

                    default:
                        list.Add(session.GetHabbo().GetInventoryComponent().AddNewItem(0u, item.Name, extraData, 0u, true, false, limno, limtot));
                        break;
                    }

                    i++;
                }

                return(list);

            case 'e':
                for (int j = 0; j < amount; j++)
                {
                    session.GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(item.SpriteId, 7200, 0);
                }
                break;

            case 'r':
                RoomBot bot = BotManager.CreateBotFromCatalog(item.Name, session.GetHabbo().Id);
                session.GetHabbo().GetInventoryComponent().AddBot(bot);
                session.SendMessage(session.GetHabbo().GetInventoryComponent().SerializeBotInventory());
                break;
            }

            return(list);
        }