Exemplo n.º 1
0
        /// <summary>
        ///     Gives the badge.
        /// </summary>
        /// <param name="badge">The badge.</param>
        /// <param name="inDatabase">if set to <c>true</c> [in database].</param>
        /// <param name="session">The session.</param>
        /// <param name="wiredReward">if set to <c>true</c> [wired reward].</param>
        internal void GiveBadge(string badge, bool inDatabase, GameClient session, bool wiredReward = false)
        {
            if (wiredReward)
                session.SendMessage(SerializeBadgeReward(!HasBadge(badge)));

            if (HasBadge(badge))
                return;

            if (inDatabase)
            {
                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery(
                        string.Concat("INSERT INTO users_badges (user_id,badge_id,badge_slot) VALUES (", _userId,
                            ",@badge,", 0, ")"));

                    queryReactor.AddParameter("badge", badge);
                    queryReactor.RunQuery();
                }
            }

            BadgeList.Add(badge, new Badge(badge, 0));

            session.SendMessage(SerializeBadge(badge));
            session.SendMessage(Update(badge));
        }
Exemplo n.º 2
0
Arquivo: About.cs Projeto: sgf/Yupi
        public override bool Execute(GameClient client, string[] pms)
        {
            ServerMessage message =
                new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));

            message.AppendString("Yupi");
            message.AppendInteger(4);
            message.AppendString("title");
            message.AppendString("Yupi");
            message.AppendString("message");
            StringBuilder info = new StringBuilder();
            info.Append("<h5><b>Yupi - Based on Azure Emulator</b><h5></br></br>");
            info.Append("<br />");
            info.AppendFormat(
                "<b><br />Developed by:</b> <br />Kessiler Rodrigues (Kessiler)<br />Claudio Santoro (sant0ro/bi0s) <br />Rafael Oliveira (iPlezier) <br /><br /> ");
            info.AppendFormat(
                "<b>Thanks to:</b> <br />Jamal, Mike Santifort, Martinmine, Rockster, The old Azure Team, Bruna F., and to all people that uses Yupi.<br /> <br /> ");
            info.AppendFormat("<b>Warning:</b><br />1. This emulator was planned to be used for ManiaHotel (maniahotel.com.br)  <br />2. Please don't sell this emulator or earn money with it<br />3. All rights reserved to Sulake Corporation Oy<br />4. All Emulator rights for Mania Dev<br />");
            message.AppendString(info.ToString());
            message.AppendString("linkUrl");
            message.AppendString("event:");
            message.AppendString("linkTitle");
            message.AppendString("ok");
            client.SendMessage(message);

            return true;
        }
Exemplo n.º 3
0
Arquivo: PickPets.cs Projeto: sgf/Yupi
 public override bool Execute(GameClient session, string[] pms)
 {
     Room room = session.GetHabbo().CurrentRoom;
     foreach (
         Pet pet in
             room.GetRoomUserManager().GetPets().Where(pet => pet.OwnerId == session.GetHabbo().Id))
     {
         session.GetHabbo().GetInventoryComponent().AddPet(pet);
         room.GetRoomUserManager().RemoveBot(pet.VirtualId, false);
     }
     session.SendMessage(session.GetHabbo().GetInventoryComponent().SerializePetInventory());
     return true;
 }
Exemplo n.º 4
0
        public override void OnUserWalk(GameClient session, RoomItem item, RoomUser user)
        {
            if (item == null || user == null)
                return;

            string[] data = item.ExtraData.Split(Convert.ToChar(9));

            if (item.ExtraData == "" || data.Length < 4)
                return;

            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("InternalLinkMessageComposer"));

            message.AppendString(data[3]);
            session.SendMessage(message);
        }
Exemplo n.º 5
0
        public override bool Execute(GameClient session, string[] pms)
        {
            if (ServerExtraSettings.NewPageCommands)
            {
                session.SendMessage(StaticMessage.NewWayToOpenCommandsList);
                return true;
            }

            string commandList;
            if (pms.Length == 0)
            {
                commandList =
                    CommandsManager.CommandsDictionary.Where(
                        command => CommandsManager.CanUse(command.Value.MinRank, session))
                        .Aggregate(string.Empty,
                            (current, command) =>
                                current + command.Value.Usage + " - " + command.Value.Description + "\n");
            }
            else
            {
                if (pms[0].Length == 1)
                {
                    commandList =
                        CommandsManager.CommandsDictionary.Where(
                            command =>
                                command.Key.StartsWith(pms[0]) && CommandsManager.CanUse(command.Value.MinRank, session))
                            .Aggregate(string.Empty,
                                (current, command) =>
                                    current + command.Value.Usage + " - " + command.Value.Description + "\n");
                }
                else
                {
                    commandList =
                        CommandsManager.CommandsDictionary.Where(
                            command =>
                                command.Key.Contains(pms[0]) && CommandsManager.CanUse(command.Value.MinRank, session))
                            .Aggregate(string.Empty,
                                (current, command) =>
                                    current + command.Value.Usage + " - " + command.Value.Description + "\n");
                }
            }
            session.SendNotifWithScroll(commandList);

            return true;
        }
Exemplo n.º 6
0
        public override bool Execute(GameClient session, string[] pms)
        {
            GameClient client = Yupi.GetGame().GetClientManager().GetClientByUserName(pms[0]);
            if (client == null || client.GetHabbo() == null)
            {
                session.SendWhisper(Yupi.GetLanguage().GetVar("user_not_found"));
                return true;
            }
            if (client.GetHabbo().CurrentRoom == null ||
                client.GetHabbo().CurrentRoom == session.GetHabbo().CurrentRoom)
                return false;
            ServerMessage roomFwd =
                new ServerMessage(LibraryParser.OutgoingRequest("RoomForwardMessageComposer"));
            roomFwd.AppendInteger(client.GetHabbo().CurrentRoom.RoomId);
            session.SendMessage(roomFwd);

            return true;
        }
Exemplo n.º 7
0
        internal static void GenerateMessage(Pet pet, Dictionary<uint, PetCommand> totalPetCommands, Dictionary<uint, PetCommand> petCommands, GameClient owner)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer"));

            serverMessage.AppendInteger(pet.PetId);

            serverMessage.AppendInteger(totalPetCommands.Count);

            foreach (uint sh in totalPetCommands.Keys)
                serverMessage.AppendInteger(sh);

            serverMessage.AppendInteger(petCommands.Count);

            foreach (uint sh in petCommands.Keys)
                serverMessage.AppendInteger(sh);

            owner.SendMessage(serverMessage);
        }
Exemplo n.º 8
0
        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            Habbo user = session.GetHabbo();
            bool ishc = user.Vip;

            if (!ishc)
            {
                ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("CustomUserNotificationMessageComposer"));
                message.AppendInteger(3);
                session.SendMessage(message);
                return;
            }

            if (item?.GetBaseItem() == null || item.GetBaseItem().InteractionType != Interaction.HcGate)
                return;

            uint modes = item.GetBaseItem().Modes - 1;

            if (modes <= 0)
                item.UpdateState(false, true);

            int currentMode;
            int.TryParse(item.ExtraData, out currentMode);
            int newMode;

            if (currentMode <= 0)
                newMode = 1;
            else if (currentMode >= modes)
                newMode = 0;
            else
                newMode = currentMode + 1;

            if (newMode == 0 && !item.GetRoom().GetGameMap().ItemCanBePlacedHere(item.X, item.Y))
                return;

            item.ExtraData = newMode.ToString();
            item.UpdateState();
            item.GetRoom().GetGameMap().UpdateMapForItem(item);
            item.GetRoom()
                .GetWiredHandler()
                .ExecuteWired(Interaction.TriggerStateChanged,
                    item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id), item);
        }
Exemplo n.º 9
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:
                                string[] petData = extraData.Split('\n');

                                Pet generatedPet = CreatePet(session.GetHabbo().Id, petData[0], item.Name, petData[1],
                                    petData[2]);

                                session.GetHabbo().GetInventoryComponent().AddPet(generatedPet);
                                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;
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Enables the new navigator.
        /// </summary>
        /// <param name="session">The session.</param>
        internal void EnableNewNavigator(GameClient session)
        {
            ServerMessage navigatorMetaDataParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorMetaDataComposer"));

            navigatorMetaDataParser.AppendInteger(4);
            navigatorMetaDataParser.AppendString("official_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("hotel_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("roomads_view");
            navigatorMetaDataParser.AppendInteger(0);
            navigatorMetaDataParser.AppendString("myworld_view");
            navigatorMetaDataParser.AppendInteger(0);
            session.SendMessage(navigatorMetaDataParser);

            ServerMessage navigatorLiftedRoomsParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorLiftedRoomsComposer"));
            navigatorLiftedRoomsParser.AppendInteger(NavigatorHeaders.Count);

            foreach (NavigatorHeader navHeader in NavigatorHeaders)
            {
                navigatorLiftedRoomsParser.AppendInteger(navHeader.RoomId);
                navigatorLiftedRoomsParser.AppendInteger(0);
                navigatorLiftedRoomsParser.AppendString(navHeader.Image);
                navigatorLiftedRoomsParser.AppendString(navHeader.Caption);
            }

            session.SendMessage(navigatorLiftedRoomsParser);

            ServerMessage collapsedCategoriesMessageParser = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorCategorys"));

            collapsedCategoriesMessageParser.AppendInteger(FlatCatsCount + 4);

            foreach (PublicCategory flat in PrivateCategories.Values)
                collapsedCategoriesMessageParser.AppendString($"category__{flat.Caption}");

            collapsedCategoriesMessageParser.AppendString("recommended");
            collapsedCategoriesMessageParser.AppendString("new_ads");
            collapsedCategoriesMessageParser.AppendString("staffpicks");
            collapsedCategoriesMessageParser.AppendString("official");
            session.SendMessage(collapsedCategoriesMessageParser);

            ServerMessage searches = new ServerMessage(LibraryParser.OutgoingRequest("NavigatorSavedSearchesComposer"));

            searches.AppendInteger(session.GetHabbo().NavigatorLogs.Count);

            foreach (UserSearchLog navi in session.GetHabbo().NavigatorLogs.Values)
            {
                searches.AppendInteger(navi.Id);
                searches.AppendString(navi.Value1);
                searches.AppendString(navi.Value2);
                searches.AppendString("");
            }

            session.SendMessage(searches);

            ServerMessage packetName = new ServerMessage(LibraryParser.OutgoingRequest("NewNavigatorSizeMessageComposer"));
            UserPreferences pref = session.GetHabbo().Preferences;

            packetName.AppendInteger(pref.NewnaviX);
            packetName.AppendInteger(pref.NewnaviY);
            packetName.AppendInteger(pref.NewnaviWidth);
            packetName.AppendInteger(pref.NewnaviHeight);
            packetName.AppendBool(false);
            packetName.AppendInteger(1);

            session.SendMessage(packetName);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Handles the purchase.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="pageId">The page identifier.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="extraData">The extra data.</param>
        /// <param name="priceAmount">The price amount.</param>
        /// <param name="isGift">if set to <c>true</c> [is gift].</param>
        /// <param name="giftUser">The gift user.</param>
        /// <param name="giftMessage">The gift message.</param>
        /// <param name="giftSpriteId">The gift sprite identifier.</param>
        /// <param name="giftLazo">The gift lazo.</param>
        /// <param name="giftColor">Color of the gift.</param>
        /// <param name="undef">if set to <c>true</c> [undef].</param>
        /// <param name="theGroup">The theGroup.</param>
        internal void HandlePurchase(GameClient session, uint pageId, uint itemId, string extraData, uint priceAmount,
            bool isGift, string giftUser, string giftMessage, int giftSpriteId, int giftLazo, int giftColor, bool undef,
            uint theGroup)
        {
            priceAmount = priceAmount < 1 || priceAmount > 100 ? 1 : priceAmount;

            uint totalPrice = priceAmount, limitedId = 0, limtot = 0;

            if (priceAmount >= 6)
                totalPrice -= Convert.ToUInt32(Math.Ceiling(Convert.ToDouble(priceAmount)/6))*2 - 1;

            if (!Categories.Contains(pageId))
                return;

            CatalogPage catalogPage = GetPage(pageId);

            if (catalogPage == null || !catalogPage.Enabled || !catalogPage.Visible || session?.GetHabbo() == null || catalogPage.MinRank > session.GetHabbo().Rank || catalogPage.Layout == "sold_ltd_items")
                return;

            CatalogItem item = catalogPage.GetItem(itemId);

            if (item == null || session.GetHabbo().Credits < item.CreditsCost || session.GetHabbo().Duckets < item.DucketsCost || session.GetHabbo().Diamonds < item.DiamondsCost || item.Name == "room_ad_plus_badge")
                return;

            #region Habbo Club Purchase

            if (catalogPage.Layout == "vip_buy" || catalogPage.Layout == "club_buy" || HabboClubItems.Contains(item))
            {
                string[] array = item.Name.Split('_');

                double dayLength = 31;

                if (item.Name.Contains("DAY"))
                    dayLength = double.Parse(array[3]);
                else if (item.Name.Contains("MONTH"))
                    dayLength = Math.Ceiling(double.Parse(array[3])*31 - 0.205);
                else if (item.Name.Contains("YEAR"))
                    dayLength = double.Parse(array[3])*31*12;

                session.GetHabbo().GetSubscriptionManager().AddSubscription(dayLength);

                if (item.CreditsCost > 0)
                {
                    session.GetHabbo().Credits -= item.CreditsCost*totalPrice;
                    session.GetHabbo().UpdateCreditsBalance();
                }

                if (item.DucketsCost > 0)
                {
                    session.GetHabbo().Duckets -= item.DucketsCost*totalPrice;
                    session.GetHabbo().UpdateActivityPointsBalance();
                }

                if (item.DiamondsCost > 0)
                {
                    session.GetHabbo().Diamonds -= item.DiamondsCost*totalPrice;
                    session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }

                return;
            }

            #endregion

            #region Is Only for Habbo Club users Check

            if (item.ClubOnly && !session.GetHabbo().GetSubscriptionManager().HasSubscription)
            {
                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("CatalogPurchaseNotAllowedMessageComposer"));
                serverMessage.AppendInteger(1);
                session.SendMessage(serverMessage);
                return;
            }

            #endregion

            #region Limited Items Purchase

            if (item.IsLimited)
            {
                totalPrice = 1;
                priceAmount = 1;

                if (item.LimitedSelled >= item.LimitedStack)
                {
                    session.SendMessage(new ServerMessage(LibraryParser.OutgoingRequest("CatalogLimitedItemSoldOutMessageComposer")));
                    return;
                }

                item.LimitedSelled++;

                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.RunFastQuery(string.Concat("UPDATE catalog_items SET limited_sells = ",
                        item.LimitedSelled, " WHERE id = ", item.Id));

                    limitedId = item.LimitedSelled;
                    limtot = item.LimitedStack;
                }
            }
            else if (isGift && priceAmount > 1)
            {
                totalPrice = 1;
                priceAmount = 1;
            }

            #endregion

            uint toUserId = 0u;

            if (session.GetHabbo().Credits < item.CreditsCost*totalPrice || session.GetHabbo().Duckets < item.DucketsCost * totalPrice || session.GetHabbo().Diamonds < item.DiamondsCost * totalPrice)
                return;

            #region Decrease User Balance with Item Cost

            if (!isGift)
            {
                if (item.CreditsCost > 0)
                {
                    session.GetHabbo().Credits -= item.CreditsCost*totalPrice;
                    session.GetHabbo().UpdateCreditsBalance();
                }

                if (item.DucketsCost > 0)
                {
                    session.GetHabbo().Duckets -= item.DucketsCost*totalPrice;
                    session.GetHabbo().UpdateActivityPointsBalance();
                }

                if (item.DiamondsCost > 0)
                {
                    session.GetHabbo().Diamonds -= item.DiamondsCost*totalPrice;
                    session.GetHabbo().UpdateSeasonalCurrencyBalance();
                }
            }

            #endregion

            foreach (Item baseItem in item.Items.Keys)
            {
                #region Stack if Gift

                if (isGift)
                {
                    if ((DateTime.Now - session.GetHabbo().LastGiftPurchaseTime).TotalSeconds <= 15.0)
                    {
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_send_gift"));

                        return;
                    }

                    if (!baseItem.AllowGift)
                        return;

                    DataRow row;

                    using (IQueryAdapter queryreactor3 = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryreactor3.SetQuery("SELECT id FROM users WHERE username = @gift_user");
                        queryreactor3.AddParameter("gift_user", giftUser);
                        row = queryreactor3.GetRow();
                    }

                    if (row == null)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    toUserId = (uint) row["id"];

                    if (toUserId == 0u)
                    {
                        session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("GiftErrorMessageComposer"));
                        session.GetMessageHandler().GetResponse().AppendString(giftUser);
                        session.GetMessageHandler().SendResponse();

                        return;
                    }

                    if (item.CreditsCost > 0)
                    {
                        session.GetHabbo().Credits -= item.CreditsCost*totalPrice;
                        session.GetHabbo().UpdateCreditsBalance();
                    }

                    if (item.DucketsCost > 0)
                    {
                        session.GetHabbo().Duckets -= item.DucketsCost*totalPrice;
                        session.GetHabbo().UpdateActivityPointsBalance();
                    }

                    if (item.DiamondsCost > 0)
                    {
                        session.GetHabbo().Diamonds -= item.DiamondsCost*totalPrice;
                        session.GetHabbo().UpdateSeasonalCurrencyBalance();
                    }

                    if (baseItem.Type == 'e')
                    {
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_send_gift_effect"));

                        return;
                    }
                }

                #endregion

                #region Item is Builders Club Addon

                if (item.Name.StartsWith("builders_club_addon_"))
                {
                    int furniAmount = int.Parse(item.Name.Replace("builders_club_addon_", string.Empty).Replace("furnis", string.Empty));

                    session.GetHabbo().BuildersItemsMax += furniAmount;

                    ServerMessage update = new ServerMessage(LibraryParser.OutgoingRequest("BuildersClubMembershipMessageComposer"));

                    update.AppendInteger(session.GetHabbo().BuildersExpire);
                    update.AppendInteger(session.GetHabbo().BuildersItemsMax);
                    update.AppendInteger(2);
                    session.SendMessage(update);

                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.SetQuery("UPDATE users SET builders_items_max = @max WHERE id = @userId");
                        queryReactor.AddParameter("max", session.GetHabbo().BuildersItemsMax);
                        queryReactor.AddParameter("userId", session.GetHabbo().Id);
                        queryReactor.RunQuery();
                    }

                    session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));
                    session.SendNotif("${notification.builders_club.membership_extended.message}", "${notification.builders_club.membership_extended.title}", "builders_club_membership_extended");

                    return;
                }

                #endregion

                #region Item is Builders Club Upgrade

                if (item.Name.StartsWith("builders_club_time_"))
                {
                    int timeAmount = int.Parse(item.Name.Replace("builders_club_time_", string.Empty).Replace("seconds", string.Empty));

                    session.GetHabbo().BuildersExpire += timeAmount;

                    ServerMessage update = new ServerMessage(LibraryParser.OutgoingRequest("BuildersClubMembershipMessageComposer"));

                    update.AppendInteger(session.GetHabbo().BuildersExpire);
                    update.AppendInteger(session.GetHabbo().BuildersItemsMax);
                    update.AppendInteger(2);
                    session.SendMessage(update);

                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.SetQuery("UPDATE users SET builders_expire = @max WHERE id = @userId");
                        queryReactor.AddParameter("max", session.GetHabbo().BuildersExpire);
                        queryReactor.AddParameter("userId", session.GetHabbo().Id);
                        queryReactor.RunQuery();
                    }

                    session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));
                    session.SendNotif("${notification.builders_club.membership_extended.message}", "${notification.builders_club.membership_extended.title}", "builders_club_membership_extended");

                    return;
                }

                #endregion

                string text = string.Empty;

                #region Interaction Type Selection

                Interaction interactionType = baseItem.InteractionType;

                switch (interactionType)
                {
                    case Interaction.None:
                    case Interaction.Gate:
                    case Interaction.Bed:
                    case Interaction.PressurePadBed:
                    case Interaction.Guillotine:
                    case Interaction.HcGate:
                    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.Teleport:
                    case Interaction.QuickTeleport:
                    case Interaction.Pet:
                    case Interaction.Pool:
                    case Interaction.Roller:
                        break;

                    case Interaction.PostIt:
                        extraData = "FFFF33";
                        break;

                    case Interaction.RoomEffect:
                        double number = string.IsNullOrEmpty(extraData) ? 0.0 : double.Parse(extraData, Yupi.CultureInfo);

                        extraData = number.ToString(CultureInfo.InvariantCulture).Replace(',', '.');
                        break;

                    case Interaction.Dimmer:
                        extraData = "1,1,1,#000000,255";
                        break;

                    case Interaction.Trophy:
                        extraData = string.Concat(session.GetHabbo().UserName, Convert.ToChar(9),
                            DateTime.Now.Day.ToString("00"), "-", DateTime.Now.Month.ToString("00"), "-",
                            DateTime.Now.Year, Convert.ToChar(9), extraData);
                        break;

                    case Interaction.Rentals:
                        extraData = item.ExtraData;
                        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.PetCafeRabbit:
                    case Interaction.PetPigeon:
                    case Interaction.PetEvilPigeon:
                    case Interaction.PetDemonMonkey:
                        string[] data = extraData.Split('\n');
                        string petName = data[0];
                        string race = data[1];
                        string color = data[2];

                        if (!CheckPetName(petName) || (race.Length != 1 && race.Length != 2) || color.Length != 6)
                            return;
                        break;

                    case Interaction.Mannequin:
                        extraData = string.Concat("m", Convert.ToChar(5), "lg-270-82.ch-210-66", Convert.ToChar(5), "Mannequin");
                        break;

                    case Interaction.VipGate:
                    case Interaction.MysteryBox:
                    case Interaction.YoutubeTv:
                    case Interaction.TileStackMagic:
                    case Interaction.Tent:
                    case Interaction.BedTent:
                        break;

                    case Interaction.BadgeDisplay:
                        if (!session.GetHabbo().GetBadgeComponent().HasBadge(extraData))
                            extraData = "UMAD";

                        extraData = $"{extraData}|{session.GetHabbo().UserName}|{DateTime.Now.Day.ToString("00")}-{DateTime.Now.Month.ToString("00")}-{DateTime.Now.Year}";
                        break;

                    case Interaction.FootballGate:
                        extraData = "hd-99999-99999.lg-270-62;hd-99999-99999.ch-630-62.lg-695-62";
                        break;

                    case Interaction.LoveLock:
                        extraData = "0";
                        break;

                    case Interaction.Pinata:
                    case Interaction.RunWaySage:
                    case Interaction.Shower:
                        extraData = "0";
                        break;

                    case Interaction.GroupForumTerminal:
                    case Interaction.GuildItem:
                    case Interaction.GuildGate:
                    case Interaction.GuildForum:
                    case Interaction.Poster:
                        break;

                    case Interaction.Moplaseed:
                        extraData = new Random().Next(0, 12).ToString();
                        break;

                    case Interaction.RareMoplaSeed:
                        extraData = new Random().Next(10, 12).ToString();
                        break;

                    case Interaction.MusicDisc:

                        SongData song = SoundMachineSongManager.GetSongById(item.SongId);

                        extraData = string.Empty;

                        if (song == null)
                            break;

                        extraData = string.Concat(session.GetHabbo().UserName, '\n', DateTime.Now.Year, '\n',
                            DateTime.Now.Month, '\n', DateTime.Now.Day, '\n', song.LengthSeconds, '\n', song.Name);

                        text = song.CodeName;

                        break;

                    default:
                        extraData = item.ExtraData;
                        break;
                }

                #endregion

                session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("UpdateInventoryMessageComposer"));

                session.GetMessageHandler().SendResponse();

                session.SendMessage(CatalogPageComposer.PurchaseOk(item, item.Items));

                if (isGift)
                {
                    Item itemBySprite = Yupi.GetGame().GetItemManager().GetItemBySpriteId(giftSpriteId);

                    if (itemBySprite == null)
                        return;

                    uint insertId;

                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.SetQuery("INSERT INTO items_rooms (item_name,user_id) VALUES (" + itemBySprite.Name + ", " + toUserId + ")");

                        insertId = (uint) queryReactor.InsertQuery();

                        queryReactor.SetQuery(
                            string.Concat(
                                "INSERT INTO users_gifts (gift_id,item_id,extradata,giver_name,Message,ribbon,color,gift_sprite,show_sender,rare_id) VALUES (",
                                insertId, ", ", baseItem.ItemId, ",@extradata, @name, @Message,", giftLazo, ",",
                                giftColor, ",", giftSpriteId, ",", undef ? 1 : 0, ",", limitedId, ")"));
                        queryReactor.AddParameter("extradata", extraData);
                        queryReactor.AddParameter("name", giftUser);
                        queryReactor.AddParameter("message", giftMessage);
                        queryReactor.RunQuery();

                        if (session.GetHabbo().Id != toUserId)
                        {
                            Yupi.GetGame()
                                .GetAchievementManager()
                                .ProgressUserAchievement(session, "ACH_GiftGiver", 1, true);

                            queryReactor.RunFastQuery(
                                "UPDATE users_stats SET gifts_given = gifts_given + 1 WHERE id = " +
                                session.GetHabbo().Id +
                                ";UPDATE users_stats SET gifts_received = gifts_received + 1 WHERE id = " + toUserId);
                        }
                    }

                    GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(toUserId);

                    if (clientByUserId != null)
                    {
                        clientByUserId.GetHabbo()
                            .GetInventoryComponent()
                            .AddNewItem(insertId, itemBySprite.Name,
                                string.Concat(session.GetHabbo().Id, (char) 9, giftMessage, (char) 9, giftLazo, (char) 9,
                                    giftColor, (char) 9, undef ? "1" : "0", (char) 9, session.GetHabbo().UserName,
                                    (char) 9, session.GetHabbo().Look, (char) 9, item.Name), 0u, false, false, 0, 0);

                        if (clientByUserId.GetHabbo().Id != session.GetHabbo().Id)
                            Yupi.GetGame()
                                .GetAchievementManager()
                                .ProgressUserAchievement(clientByUserId, "ACH_GiftReceiver", 1, true);
                    }

                    session.GetHabbo().LastGiftPurchaseTime = DateTime.Now;

                    continue;
                }

                session.GetMessageHandler()
                    .GetResponse()
                    .Init(LibraryParser.OutgoingRequest("NewInventoryObjectMessageComposer"));

                session.GetMessageHandler().GetResponse().AppendInteger(1);

                int i = 1;

                if (baseItem.Type == 's')
                    i = InteractionTypes.AreFamiliar(GlobalInteractions.Pet, baseItem.InteractionType) ? 3 : 1;

                session.GetMessageHandler().GetResponse().AppendInteger(i);

                List<UserItem> list = DeliverItems(session, baseItem, priceAmount*item.Items[baseItem], extraData, limitedId,
                    limtot, text);

                session.GetMessageHandler().GetResponse().AppendInteger(list.Count);

                foreach (UserItem current3 in list)
                    session.GetMessageHandler().GetResponse().AppendInteger(current3.Id);

                session.GetMessageHandler().SendResponse();

                session.GetHabbo().GetInventoryComponent().UpdateItems(false);

                if (InteractionTypes.AreFamiliar(GlobalInteractions.Pet, baseItem.InteractionType))
                    session.SendMessage(session.GetHabbo().GetInventoryComponent().SerializePetInventory());
            }

            if (item.Badge.Length >= 1)
                session.GetHabbo().GetBadgeComponent().GiveBadge(item.Badge, true, session);
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Progresses the user achievement.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="achievementGroup">The achievement group.</param>
        /// <param name="progressAmount">The progress amount.</param>
        /// <param name="fromZero">if set to <c>true</c> [from zero].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool ProgressUserAchievement(GameClient session, string achievementGroup, uint progressAmount,
            bool fromZero = false)
        {
            if (Achievements.ContainsKey(achievementGroup) && session?.GetHabbo() != null)
            {
                Achievement achievement = Achievements[achievementGroup];

                Habbo user = session.GetHabbo();

                // Get UserAchievementData, if the user doesn't has the Achievement, create a new.
                UserAchievement userAchievement = user.Achievements.ContainsKey(achievementGroup)
                    ? user.GetAchievementData(achievementGroup)
                    : new UserAchievement(achievementGroup, 0, 0);

                // If is a New Achievement is fromZero
                if (!user.Achievements.ContainsKey(achievementGroup))
                    fromZero = true;

                // If user hasn't the Achievement, after created the new, Must add in Collections.
                if (!user.Achievements.ContainsKey(achievementGroup))
                    user.Achievements.Add(achievementGroup, userAchievement);

                // Get Achievement 
                userAchievement = user.Achievements[achievementGroup];

                // Total Levels from this Achievement
                uint achievementLevelsCount = (uint) achievement.Levels.Count;

                // Get User Achievement Level
                uint achievementCurrentLevel = userAchievement.Level;

                // Get User Achievement Progress
                uint achievementCurrentProgress = userAchievement.Progress;

                // If the next Level is the last level must set to Levels.Count (Ex: 38 Levels => .Count = 37 (Max Level in the Array, but .Count 37 == 38, Soo need put Level - 1)
                uint achievementNextLevel = achievementCurrentLevel + 1 > achievementLevelsCount
                    ? achievementLevelsCount
                    : achievementCurrentLevel + 1;

                // Set Achievement Progress
                uint achievementProgress = achievementCurrentProgress + progressAmount;

                // If he has already the Max, something is wrong.
                if (achievementCurrentLevel == achievementLevelsCount)
                    return false;

                // Get Next Level Data
                AchievementLevel achievementNextLevelData = achievement.Levels[achievementNextLevel];

                // if progress isn't sufficient or, isn't new Achievement
                if (achievementProgress < achievementNextLevelData.Requirement || achievementCurrentLevel >= 1)
                    fromZero = false;

                // If progress is sufficient to next level, or is new Achievement
                if (achievementProgress >= achievementNextLevelData.Requirement || (achievementCurrentLevel < 1))
                    fromZero = true;

                // if is a new level (but level isn't 0)
                if (achievementProgress >= achievementNextLevelData.Requirement)
                    achievementProgress = 0;

                // If is new Level
                if (fromZero)
                {
                    // Set Level
                    userAchievement.SetLevel(achievementNextLevel);

                    // Set Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Give Reward Points
                    user.AchievementPoints += achievementNextLevelData.RewardPoints;
                    user.NotifyNewPixels(achievementNextLevelData.RewardPixels);
                    user.Duckets += achievementNextLevelData.RewardPixels;

                    // Update Points Balance
                    user.UpdateActivityPointsBalance();

                    // Remove old Badge - (Is not problem if is First Level Badge, because if the user hasn't the badg, simply, will not remove.
                    user.GetBadgeComponent()
                        .RemoveBadge(Convert.ToString($"{achievementGroup}{achievementNextLevel - 1}"), session);

                    // Give new Badge
                    user.GetBadgeComponent().GiveBadge($"{achievementGroup}{achievementNextLevel}", true, session);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementNextLevel}', '{achievementProgress}')");

                    // Send Unlocked Composer
                    session.SendMessage(AchievementUnlockedComposer.Compose(achievement, achievementNextLevel,
                        achievementNextLevelData.RewardPoints, achievementNextLevelData.RewardPixels));

                    // Send Score Composer
                    session.SendMessage(AchievementScoreUpdateComposer.Compose(user.AchievementPoints));

                    // Send Progress Composer
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementNextLevel,
                        achievementNextLevelData, achievementLevelsCount, userAchievement));

                    // Set Talent
                    if (
                        Yupi.GetGame()
                            .GetTalentManager()
                            .Talents.Values.Any(talent => talent.AchievementGroup == achievementGroup))
                        Yupi.GetGame()
                            .GetTalentManager()
                            .CompleteUserTalent(session,
                                Yupi.GetGame().GetTalentManager().GetTalentData(achievementGroup));
                }
                else
                {
                    // Get Current Level Data
                    AchievementLevel achievementCurrentLevelData = achievement.Levels[achievementCurrentLevel];

                    // It's the Same Level
                    userAchievement.SetLevel(achievementCurrentLevel);

                    // But increase Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementCurrentLevel}', '{achievementProgress}')");

                    // Compose Current Data
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementCurrentLevel,
                        achievementCurrentLevelData, achievementLevelsCount, userAchievement));
                }

                // Send User New Data
                GameClientMessageHandler messageHandler = session.GetMessageHandler();

                messageHandler.GetResponse().Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                messageHandler.GetResponse().AppendInteger(-1);
                messageHandler.GetResponse().AppendString(user.Look);
                messageHandler.GetResponse().AppendString(user.Gender.ToLower());
                messageHandler.GetResponse().AppendString(user.Motto);
                messageHandler.GetResponse().AppendInteger(user.AchievementPoints);

                messageHandler.SendResponse();

                return true;
            }

            return false;
        }
Exemplo n.º 13
0
 /// <summary>
 ///     Activates the quest.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 internal void ActivateQuest(GameClient session, ClientMessage message)
 {
     var quest = GetQuest(message.GetInteger());
     if (quest == null)
         return;
     using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
     {
         queryReactor.RunFastQuery(string.Concat("REPLACE INTO users_quests_data(user_id,quest_id) VALUES (",
             session.GetHabbo().Id, ", ", quest.Id, ")"));
         queryReactor.RunFastQuery(string.Concat("UPDATE users_stats SET quest_id = ", quest.Id, " WHERE id = ",
             session.GetHabbo().Id));
     }
     session.GetHabbo().CurrentQuestId = quest.Id;
     GetList(session, null);
     session.SendMessage(QuestStartedComposer.Compose(session, quest));
 }
Exemplo n.º 14
0
        /// <summary>
        ///     Completes the user talent.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="talent">The talent.</param>
        internal void CompleteUserTalent(GameClient session, Talent talent)
        {
            if (session?.GetHabbo() == null || session.GetHabbo().CurrentTalentLevel < talent.Level || session.GetHabbo().Talents.ContainsKey(talent.Id))
                return;

            if (!LevelIsCompleted(session, talent.Type, talent.Level))
                return;

            if (!string.IsNullOrEmpty(talent.Prize) && talent.PrizeBaseItem > 0u)
                Yupi.GetGame().GetCatalog().DeliverItems(session, Yupi.GetGame().GetItemManager().GetItem(talent.PrizeBaseItem), 1, string.Empty, 0, 0, string.Empty);

            session.GetHabbo().Talents.Add(talent.Id, new UserTalent(talent.Id, 1));

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery($"REPLACE INTO users_talents VALUES ('{session.GetHabbo().Id}', '{talent.Id}', '1');");

            session.SendMessage(AchievementTalentComposer.Compose(session, talent));

            if (talent.Type == "citizenship")
            {
                switch (talent.Level)
                {
                    case 3:
                        Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(session, "ACH_Citizenship", 1);
                        break;
                    case 4:
                        session.GetHabbo().GetSubscriptionManager().AddSubscription(7);

                        using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                            queryReactor.RunFastQuery($"UPDATE users SET talent_status = 'helper' WHERE id = '{session.GetHabbo().Id}'");
                        break;
                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 ///     Gets the list.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 internal void GetList(GameClient session, ClientMessage message)
     => session.SendMessage(AchievementListComposer.Compose(session, Achievements.Values.ToList()));
Exemplo n.º 16
0
 /// <summary>
 ///     Gets the list.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 internal void GetList(GameClient session, ClientMessage message)
 {
     session.SendMessage(QuestListComposer.Compose(session, _quests.Values.ToList(), message != null));
 }
Exemplo n.º 17
0
        /// <summary>
        ///     Gets the current quest.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        internal void GetCurrentQuest(GameClient session, ClientMessage message)
        {
            if (!session.GetHabbo().InRoom)
                return;
            var quest = GetQuest(session.GetHabbo().LastQuestCompleted);
            var nextQuestInSeries = GetNextQuestInSeries(quest.Category, quest.Number + 1);

            if (nextQuestInSeries == null)
                return;
            using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.RunFastQuery(string.Concat("REPLACE INTO users_quests_data(user_id,quest_id) VALUES (",
                    session.GetHabbo().Id, ", ", nextQuestInSeries.Id, ")"));
                queryReactor.RunFastQuery(string.Concat("UPDATE users_stats SET quest_id = ", nextQuestInSeries.Id,
                    " WHERE id = ", session.GetHabbo().Id));
            }
            session.GetHabbo().CurrentQuestId = nextQuestInSeries.Id;
            GetList(session, null);
            session.SendMessage(QuestStartedComposer.Compose(session, nextQuestInSeries));
        }
Exemplo n.º 18
0
        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (session == null || item?.GetRoom() == null || !hasRights)
                return;

            IWiredItem wired = item.GetRoom().GetWiredHandler().GetWired(item);

            if (wired == null)
                return;

            string extraInfo = wired.OtherString;
            bool flag = wired.OtherBool;
            int delay = wired.Delay/500;
            List<RoomItem> list = wired.Items.Where(roomItem => roomItem != null).ToList();
            string extraString = wired.OtherExtraString;
            string extraString2 = wired.OtherExtraString2;

            switch (item.GetBaseItem().InteractionType)
            {
                case Interaction.TriggerTimer:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(list.Count);
                    foreach (RoomItem current in list) serverMessage.AppendInteger(current.Id);
                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(extraInfo);
                    serverMessage.AppendInteger(1);
                    serverMessage.AppendInteger(delay);
                    serverMessage.AppendInteger(1);
                    serverMessage.AppendInteger(3);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                    return;
                }
                case Interaction.TriggerRoomEnter:
                {
                    ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage2.AppendBool(false);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(list.Count);
                    foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id);
                    serverMessage2.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage2.AppendInteger(item.Id);
                    serverMessage2.AppendString(extraInfo);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(7);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    session.SendMessage(serverMessage2);
                    return;
                }
                case Interaction.TriggerGameEnd:
                {
                    ServerMessage serverMessage3 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage3.AppendBool(false);
                    serverMessage3.AppendInteger(0);
                    serverMessage3.AppendInteger(list.Count);
                    foreach (RoomItem current3 in list) serverMessage3.AppendInteger(current3.Id);
                    serverMessage3.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage3.AppendInteger(item.Id);
                    serverMessage3.AppendString(extraInfo);
                    serverMessage3.AppendInteger(0);
                    serverMessage3.AppendInteger(0);
                    serverMessage3.AppendInteger(8);
                    serverMessage3.AppendInteger(0);
                    serverMessage3.AppendInteger(0);
                    serverMessage3.AppendInteger(0);
                    session.SendMessage(serverMessage3);
                    return;
                }
                case Interaction.TriggerGameStart:
                {
                    ServerMessage serverMessage4 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage4.AppendBool(false);
                    serverMessage4.AppendInteger(0);
                    serverMessage4.AppendInteger(list.Count);
                    foreach (RoomItem current4 in list) serverMessage4.AppendInteger(current4.Id);
                    serverMessage4.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage4.AppendInteger(item.Id);
                    serverMessage4.AppendString(extraInfo);
                    serverMessage4.AppendInteger(0);
                    serverMessage4.AppendInteger(0);
                    serverMessage4.AppendInteger(8);
                    serverMessage4.AppendInteger(0);
                    serverMessage4.AppendInteger(0);
                    serverMessage4.AppendInteger(0);
                    session.SendMessage(serverMessage4);
                    return;
                }
                case Interaction.TriggerLongRepeater:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString("");
                    serverMessage.AppendInteger(1);
                    serverMessage.AppendInteger(delay/10); //fix
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(12);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                    return;
                }

                case Interaction.TriggerRepeater:
                {
                    ServerMessage serverMessage5 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage5.AppendBool(false);
                    serverMessage5.AppendInteger(5);
                    serverMessage5.AppendInteger(list.Count);
                    foreach (RoomItem current5 in list) serverMessage5.AppendInteger(current5.Id);
                    serverMessage5.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage5.AppendInteger(item.Id);
                    serverMessage5.AppendString(extraInfo);
                    serverMessage5.AppendInteger(1);
                    serverMessage5.AppendInteger(delay);
                    serverMessage5.AppendInteger(0);
                    serverMessage5.AppendInteger(6);
                    serverMessage5.AppendInteger(0);
                    serverMessage5.AppendInteger(0);
                    session.SendMessage(serverMessage5);
                    return;
                }
                case Interaction.TriggerOnUserSay:
                {
                    ServerMessage serverMessage6 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage6.AppendBool(false);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(list.Count);
                    foreach (RoomItem current6 in list) serverMessage6.AppendInteger(current6.Id);
                    serverMessage6.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage6.AppendInteger(item.Id);
                    serverMessage6.AppendString(extraInfo);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(0);
                    serverMessage6.AppendInteger(0);
                    session.SendMessage(serverMessage6);
                    return;
                }
                case Interaction.TriggerScoreAchieved:
                {
                    ServerMessage serverMessage7 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage7.AppendBool(false);
                    serverMessage7.AppendInteger(5);
                    serverMessage7.AppendInteger(0);
                    serverMessage7.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage7.AppendInteger(item.Id);
                    serverMessage7.AppendString("");
                    serverMessage7.AppendInteger(1);
                    serverMessage7.AppendInteger(string.IsNullOrWhiteSpace(extraInfo) ? 100 : int.Parse(extraInfo));
                    serverMessage7.AppendInteger(0);
                    serverMessage7.AppendInteger(10);
                    serverMessage7.AppendInteger(0);
                    serverMessage7.AppendInteger(0);
                    session.SendMessage(serverMessage7);
                    return;
                }
                case Interaction.TriggerStateChanged:
                {
                    ServerMessage serverMessage8 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage8.AppendBool(false);
                    serverMessage8.AppendInteger(5);
                    serverMessage8.AppendInteger(list.Count);
                    foreach (RoomItem current8 in list) serverMessage8.AppendInteger(current8.Id);
                    serverMessage8.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage8.AppendInteger(item.Id);
                    serverMessage8.AppendString(extraInfo);
                    serverMessage8.AppendInteger(0);
                    serverMessage8.AppendInteger(0);
                    serverMessage8.AppendInteger(1);
                    serverMessage8.AppendInteger(delay);
                    serverMessage8.AppendInteger(0);
                    serverMessage8.AppendInteger(0);
                    session.SendMessage(serverMessage8);
                    return;
                }
                case Interaction.TriggerWalkOnFurni:
                {
                    ServerMessage serverMessage9 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage9.AppendBool(false);
                    serverMessage9.AppendInteger(5);
                    serverMessage9.AppendInteger(list.Count);
                    foreach (RoomItem current9 in list) serverMessage9.AppendInteger(current9.Id);
                    serverMessage9.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage9.AppendInteger(item.Id);
                    serverMessage9.AppendString(extraInfo);
                    serverMessage9.AppendInteger(0);
                    serverMessage9.AppendInteger(0);
                    serverMessage9.AppendInteger(1);
                    serverMessage9.AppendInteger(0);
                    serverMessage9.AppendInteger(0);
                    serverMessage9.AppendInteger(0);
                    session.SendMessage(serverMessage9);
                    return;
                }
                case Interaction.ActionMuteUser:
                {
                    ServerMessage serverMessage18 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage18.AppendBool(false);
                    serverMessage18.AppendInteger(5);
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage18.AppendInteger(item.Id);
                    serverMessage18.AppendString(extraInfo);
                    serverMessage18.AppendInteger(1);
                    serverMessage18.AppendInteger(delay);
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(20);
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(0);
                    session.SendMessage(serverMessage18);
                    return;
                }
                case Interaction.TriggerWalkOffFurni:
                {
                    ServerMessage serverMessage10 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage10.AppendBool(false);
                    serverMessage10.AppendInteger(5);
                    serverMessage10.AppendInteger(list.Count);
                    foreach (RoomItem current10 in list) serverMessage10.AppendInteger(current10.Id);
                    serverMessage10.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage10.AppendInteger(item.Id);
                    serverMessage10.AppendString(extraInfo);
                    serverMessage10.AppendInteger(0);
                    serverMessage10.AppendInteger(0);
                    serverMessage10.AppendInteger(1);
                    serverMessage10.AppendInteger(0);
                    serverMessage10.AppendInteger(0);
                    serverMessage10.AppendInteger(0);
                    serverMessage10.AppendInteger(0);
                    session.SendMessage(serverMessage10);
                    return;
                }

                case Interaction.TriggerCollision:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(string.Empty);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(11);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                    return;
                }

                case Interaction.ActionGiveScore:
                {
                    // Por hacer.
                    ServerMessage serverMessage11 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage11.AppendBool(false);
                    serverMessage11.AppendInteger(5);
                    serverMessage11.AppendInteger(0);
                    serverMessage11.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage11.AppendInteger(item.Id);
                    serverMessage11.AppendString("");
                    serverMessage11.AppendInteger(2);
                    if (string.IsNullOrWhiteSpace(extraInfo))
                    {
                        serverMessage11.AppendInteger(10); // Puntos a dar
                        serverMessage11.AppendInteger(1); // Numero de veces por equipo
                    }
                    else
                    {
                        string[] integers = extraInfo.Split(',');
                        serverMessage11.AppendInteger(int.Parse(integers[0])); // Puntos a dar
                        serverMessage11.AppendInteger(int.Parse(integers[1])); // Numero de veces por equipo
                    }
                    serverMessage11.AppendInteger(0);
                    serverMessage11.AppendInteger(6);
                    serverMessage11.AppendInteger(0);
                    serverMessage11.AppendInteger(0);
                    serverMessage11.AppendInteger(0);
                    session.SendMessage(serverMessage11);
                    return;
                }

                case Interaction.ConditionGroupMember:
                case Interaction.ConditionNotGroupMember:
                {
                    ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    message.AppendBool(false);
                    message.AppendInteger(5);
                    message.AppendInteger(0);
                    message.AppendInteger(item.GetBaseItem().SpriteId);
                    message.AppendInteger(item.Id);
                    message.AppendString("");
                    message.AppendInteger(0);
                    message.AppendInteger(0);
                    message.AppendInteger(10);
                    session.SendMessage(message);
                    return;
                }

                case Interaction.ConditionItemsMatches:
                case Interaction.ConditionItemsDontMatch:
                {
                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(5);
                    serverMessage21.AppendInteger(list.Count);
                    foreach (RoomItem current20 in list) serverMessage21.AppendInteger(current20.Id);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString(extraString2);
                    serverMessage21.AppendInteger(3);

                    if (string.IsNullOrWhiteSpace(extraInfo) || !extraInfo.Contains(","))
                    {
                        serverMessage21.AppendInteger(0);
                        serverMessage21.AppendInteger(0);
                        serverMessage21.AppendInteger(0);
                    }
                    else
                    {
                        string[] boolz = extraInfo.Split(',');

                        foreach (string stringy in boolz)
                            serverMessage21.AppendInteger(stringy.ToLower() == "true" ? 1 : 0);
                    }
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(0);
                    session.SendMessage(serverMessage21);
                    return;
                }

                case Interaction.ActionPosReset:
                {
                    ServerMessage serverMessage12 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage12.AppendBool(false);
                    serverMessage12.AppendInteger(5);
                    serverMessage12.AppendInteger(list.Count);
                    foreach (RoomItem current12 in list) serverMessage12.AppendInteger(current12.Id);
                    serverMessage12.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage12.AppendInteger(item.Id);
                    serverMessage12.AppendString(extraString2);
                    serverMessage12.AppendInteger(3);

                    if (string.IsNullOrWhiteSpace(extraInfo))
                    {
                        serverMessage12.AppendInteger(0);
                        serverMessage12.AppendInteger(0);
                        serverMessage12.AppendInteger(0);
                    }
                    else
                    {
                        string[] boolz = extraInfo.Split(',');

                        foreach (string stringy in boolz)
                            serverMessage12.AppendInteger(stringy.ToLower() == "true" ? 1 : 0);
                    }
                    serverMessage12.AppendInteger(0);
                    serverMessage12.AppendInteger(3);
                    serverMessage12.AppendInteger(delay); // Delay
                    serverMessage12.AppendInteger(0);
                    session.SendMessage(serverMessage12);
                    return;
                }
                case Interaction.ActionMoveRotate:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);

                    serverMessage.AppendInteger(list.Count(roomItem => roomItem != null));
                    foreach (RoomItem roomItem in list.Where(roomItem => roomItem != null))
                        serverMessage.AppendInteger(roomItem.Id);

                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(string.Empty);
                    serverMessage.AppendInteger(2);
                    serverMessage.AppendIntegersArray(extraInfo, ';', 2);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(4);
                    serverMessage.AppendInteger(delay);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                }
                    break;

                case Interaction.ActionMoveToDir:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);

                    serverMessage.AppendInteger(list.Count(roomItem => roomItem != null));
                    foreach (RoomItem roomItem in list.Where(roomItem => roomItem != null))
                        serverMessage.AppendInteger(roomItem.Id);

                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(string.Empty);
                    serverMessage.AppendInteger(2);
                    serverMessage.AppendIntegersArray(extraInfo, ';', 2);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(13);
                    serverMessage.AppendInteger(delay);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                }
                    break;

                case Interaction.ActionResetTimer:
                {
                    ServerMessage serverMessage14 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage14.AppendBool(false);
                    serverMessage14.AppendInteger(0);
                    serverMessage14.AppendInteger(0);
                    serverMessage14.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage14.AppendInteger(item.Id);
                    serverMessage14.AppendString(extraInfo);
                    serverMessage14.AppendInteger(0);
                    serverMessage14.AppendInteger(0);
                    serverMessage14.AppendInteger(1);
                    serverMessage14.AppendInteger(delay);
                    serverMessage14.AppendInteger(0);
                    serverMessage14.AppendInteger(0);
                    session.SendMessage(serverMessage14);
                    return;
                }
                case Interaction.ActionShowMessage:
                case Interaction.ActionKickUser:
                case Interaction.ActionEffectUser:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(list.Count);
                    foreach (RoomItem current15 in list) serverMessage15.AppendInteger(current15.Id);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(7);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionTeleportTo:
                {
                    ServerMessage serverMessage16 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage16.AppendBool(false);
                    serverMessage16.AppendInteger(5);

                    serverMessage16.AppendInteger(list.Count);
                    foreach (RoomItem roomItem in list) serverMessage16.AppendInteger(roomItem.Id);

                    serverMessage16.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage16.AppendInteger(item.Id);
                    serverMessage16.AppendString(extraInfo);
                    serverMessage16.AppendInteger(0);
                    serverMessage16.AppendInteger(8);
                    serverMessage16.AppendInteger(0);
                    serverMessage16.AppendInteger(delay);
                    serverMessage16.AppendInteger(0);
                    serverMessage16.AppendByte(2);
                    session.SendMessage(serverMessage16);
                    return;
                }
                case Interaction.ActionToggleState:
                {
                    ServerMessage serverMessage17 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage17.AppendBool(false);
                    serverMessage17.AppendInteger(5);
                    serverMessage17.AppendInteger(list.Count);
                    foreach (RoomItem current17 in list) serverMessage17.AppendInteger(current17.Id);
                    serverMessage17.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage17.AppendInteger(item.Id);
                    serverMessage17.AppendString(extraInfo);
                    serverMessage17.AppendInteger(0);
                    serverMessage17.AppendInteger(8);
                    serverMessage17.AppendInteger(0);
                    serverMessage17.AppendInteger(delay);
                    serverMessage17.AppendInteger(0);
                    serverMessage17.AppendInteger(0);
                    session.SendMessage(serverMessage17);
                    return;
                }
                case Interaction.ActionGiveReward:
                {
                    if (!session.GetHabbo().HasFuse("fuse_use_superwired")) return;
                    ServerMessage serverMessage18 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage18.AppendBool(false);
                    serverMessage18.AppendInteger(5);
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage18.AppendInteger(item.Id);
                    serverMessage18.AppendString(extraInfo);
                    serverMessage18.AppendInteger(3);
                    serverMessage18.AppendInteger(extraString == "" ? 0 : int.Parse(extraString));
                    serverMessage18.AppendInteger(flag ? 1 : 0);
                    serverMessage18.AppendInteger(extraString2 == "" ? 0 : int.Parse(extraString2));
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(17);
                    serverMessage18.AppendInteger(0);
                    serverMessage18.AppendInteger(0);
                    session.SendMessage(serverMessage18);
                    return;
                }

                case Interaction.ConditionHowManyUsersInRoom:
                case Interaction.ConditionNegativeHowManyUsers:
                {
                    ServerMessage serverMessage19 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage19.AppendBool(false);
                    serverMessage19.AppendInteger(5);
                    serverMessage19.AppendInteger(0);
                    serverMessage19.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage19.AppendInteger(item.Id);
                    serverMessage19.AppendString("");
                    serverMessage19.AppendInteger(2);
                    if (string.IsNullOrWhiteSpace(extraInfo))
                    {
                        serverMessage19.AppendInteger(1);
                        serverMessage19.AppendInteger(50);
                    }
                    else
                        foreach (string integers in extraInfo.Split(','))
                            serverMessage19.AppendInteger(int.Parse(integers));
                    serverMessage19.AppendBool(false);
                    serverMessage19.AppendInteger(0);
                    serverMessage19.AppendInteger(1290);
                    session.SendMessage(serverMessage19);
                    return;
                }

                case Interaction.ConditionFurnisHaveUsers:
                case Interaction.ConditionStatePos:
                case Interaction.ConditionTriggerOnFurni:
                case Interaction.ConditionFurniTypeMatches:
                case Interaction.ConditionFurnisHaveNotUsers:
                case Interaction.ConditionFurniTypeDontMatch:
                case Interaction.ConditionTriggererNotOnFurni:
                {
                    ServerMessage serverMessage19 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage19.AppendBool(false);
                    serverMessage19.AppendInteger(5);
                    serverMessage19.AppendInteger(list.Count);
                    foreach (RoomItem current18 in list) serverMessage19.AppendInteger(current18.Id);
                    serverMessage19.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage19.AppendInteger(item.Id);
                    serverMessage19.AppendInteger(0);
                    serverMessage19.AppendInteger(0);
                    serverMessage19.AppendInteger(0);
                    serverMessage19.AppendBool(false);
                    serverMessage19.AppendBool(true);
                    session.SendMessage(serverMessage19);
                    return;
                }
                case Interaction.ConditionFurniHasNotFurni:
                case Interaction.ConditionFurniHasFurni:
                {
                    ServerMessage serverMessage =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(list.Count);
                    foreach (RoomItem current18 in list) serverMessage.AppendInteger(current18.Id);
                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(string.Empty);
                    serverMessage.AppendInteger(1);
                    serverMessage.AppendInteger(flag); //bool
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(item.GetBaseItem().InteractionType == Interaction.ConditionFurniHasFurni
                        ? 7
                        : 18);
                    session.SendMessage(serverMessage);
                    return;
                }
                case Interaction.ConditionTimeLessThan:
                case Interaction.ConditionTimeMoreThan:
                {
                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString("");
                    serverMessage21.AppendInteger(1);
                    serverMessage21.AppendInteger(delay); //delay
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().InteractionType ==
                                                  Interaction.ConditionTimeMoreThan
                        ? 3
                        : 4);
                    session.SendMessage(serverMessage21);
                    return;
                }

                case Interaction.ConditionUserWearingEffect:
                case Interaction.ConditionUserNotWearingEffect:
                {
                    int effect;
                    int.TryParse(extraInfo, out effect);
                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(5);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString("");
                    serverMessage21.AppendInteger(1);
                    serverMessage21.AppendInteger(effect);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(12);
                    session.SendMessage(serverMessage21);
                    return;
                }

                case Interaction.ConditionUserWearingBadge:
                case Interaction.ConditionUserNotWearingBadge:
                case Interaction.ConditionUserHasFurni:
                {
                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(5);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString(extraInfo);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(11);
                    session.SendMessage(serverMessage21);
                    return;
                }

                case Interaction.ConditionDateRangeActive:
                {
                    int date1 = 0;
                    int date2 = 0;

                    try
                    {
                        string[] strArray = extraInfo.Split(',');
                        date1 = int.Parse(strArray[0]);
                        date2 = int.Parse(strArray[1]);
                    }
                    catch
                    {
                    }

                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(5);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString(extraInfo);
                    serverMessage21.AppendInteger(2);
                    serverMessage21.AppendInteger(date1);
                    serverMessage21.AppendInteger(date2);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(24);
                    session.SendMessage(serverMessage21);
                    return;
                }
                case Interaction.ActionJoinTeam:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(1);
                    serverMessage15.AppendInteger(delay); // Team (1-4)
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(9);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionLeaveTeam:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(10);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.TriggerBotReachedAvatar:
                {
                    ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage2.AppendBool(false);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(list.Count);
                    foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id);
                    serverMessage2.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage2.AppendInteger(item.Id);
                    serverMessage2.AppendString(extraInfo);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(14);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    session.SendMessage(serverMessage2);
                    return;
                }
                case Interaction.TriggerBotReachedStuff:
                {
                    ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("WiredTriggerMessageComposer"));
                    serverMessage2.AppendBool(false);
                    serverMessage2.AppendInteger(5);
                    serverMessage2.AppendInteger(list.Count);
                    foreach (RoomItem current2 in list) serverMessage2.AppendInteger(current2.Id);
                    serverMessage2.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage2.AppendInteger(item.Id);
                    serverMessage2.AppendString(extraInfo);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(13);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    serverMessage2.AppendInteger(0);
                    session.SendMessage(serverMessage2);
                    return;
                }
                case Interaction.ActionBotClothes:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo + (char) 9 + extraString);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(26);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotFollowAvatar:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(25);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotGiveHanditem:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(1);
                    serverMessage15.AppendInteger(delay);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(24);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotMove:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(5);
                    serverMessage15.AppendInteger(list.Count);
                    foreach (RoomItem current2 in list) serverMessage15.AppendInteger(current2.Id);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(22);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotTalk:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo + (char) 9 + extraString);
                    serverMessage15.AppendInteger(1);
                    serverMessage15.AppendInteger(Yupi.BoolToInteger(flag));
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(23);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotTalkToAvatar:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo + (char) 9 + extraString);
                    serverMessage15.AppendInteger(1);
                    serverMessage15.AppendInteger(Yupi.BoolToInteger(flag));
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(27);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionBotTeleport:
                {
                    ServerMessage serverMessage15 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage15.AppendBool(false);
                    serverMessage15.AppendInteger(5);
                    serverMessage15.AppendInteger(list.Count);
                    foreach (RoomItem current2 in list) serverMessage15.AppendInteger(current2.Id);
                    serverMessage15.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage15.AppendInteger(item.Id);
                    serverMessage15.AppendString(extraInfo);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(21);
                    serverMessage15.AppendInteger(0);
                    serverMessage15.AppendInteger(0);
                    session.SendMessage(serverMessage15);
                    return;
                }
                case Interaction.ActionChase:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);

                    serverMessage.AppendInteger(list.Count);
                    foreach (RoomItem roomItem in list) serverMessage.AppendInteger(roomItem.Id);

                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(string.Empty);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(11);
                    serverMessage.AppendInteger(0);

                    serverMessage.AppendInteger(0);

                    session.SendMessage(serverMessage);
                    return;
                }
                case Interaction.ConditionUserHasHanditem:
                {
                    ServerMessage serverMessage21 =
                        new ServerMessage(LibraryParser.OutgoingRequest("WiredConditionMessageComposer"));
                    serverMessage21.AppendBool(false);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage21.AppendInteger(item.Id);
                    serverMessage21.AppendString(extraInfo);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(0);
                    serverMessage21.AppendInteger(25);
                    session.SendMessage(serverMessage21);
                    return;
                }
                case Interaction.ActionCallStacks:
                {
                    ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage.AppendBool(false);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(list.Count);
                    foreach (RoomItem current15 in list) serverMessage.AppendInteger(current15.Id);
                    serverMessage.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(extraInfo);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(18);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(0);
                    session.SendMessage(serverMessage);
                    return;
                }

                case Interaction.ArrowPlate:
                case Interaction.PressurePad:
                case Interaction.PressurePadBed:
                case Interaction.RingPlate:
                case Interaction.ColorTile:
                case Interaction.ColorWheel:
                case Interaction.FloorSwitch1:
                case Interaction.FloorSwitch2:
                    break;

                case Interaction.SpecialRandom:
                {
                    ServerMessage serverMessage24 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage24.AppendBool(false);
                    serverMessage24.AppendInteger(5);
                    serverMessage24.AppendInteger(list.Count);
                    foreach (RoomItem current23 in list) serverMessage24.AppendInteger(current23.Id);
                    serverMessage24.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage24.AppendInteger(item.Id);
                    serverMessage24.AppendString(extraInfo);
                    serverMessage24.AppendInteger(0);
                    serverMessage24.AppendInteger(8);
                    serverMessage24.AppendInteger(0);
                    serverMessage24.AppendInteger(0);
                    serverMessage24.AppendInteger(0);
                    serverMessage24.AppendInteger(0);
                    session.SendMessage(serverMessage24);
                    return;
                }
                case Interaction.SpecialUnseen:
                {
                    ServerMessage serverMessage25 = new ServerMessage(LibraryParser.OutgoingRequest("WiredEffectMessageComposer"));
                    serverMessage25.AppendBool(false);
                    serverMessage25.AppendInteger(5);
                    serverMessage25.AppendInteger(list.Count);
                    foreach (RoomItem current24 in list) serverMessage25.AppendInteger(current24.Id);
                    serverMessage25.AppendInteger(item.GetBaseItem().SpriteId);
                    serverMessage25.AppendInteger(item.Id);
                    serverMessage25.AppendString(extraInfo);
                    serverMessage25.AppendInteger(0);
                    serverMessage25.AppendInteger(8);
                    serverMessage25.AppendInteger(0);
                    serverMessage25.AppendInteger(0);
                    serverMessage25.AppendInteger(0);
                    serverMessage25.AppendInteger(0);
                    session.SendMessage(serverMessage25);
                    return;
                }
                default:
                    return;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        ///     Serializes the theGroup information.
        /// </summary>
        /// <param name="group">The theGroup.</param>
        /// <param name="response">The response.</param>
        /// <param name="session">The session.</param>
        /// <param name="newWindow">if set to <c>true</c> [new window].</param>
        internal void SerializeGroupInfo(Group group, ServerMessage response, GameClient session, bool newWindow = false)
        {
            if (group == null || session == null)
                return;

            DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DateTime dateTime2 = dateTime.AddSeconds(group.CreateTime);

            response.Init(LibraryParser.OutgoingRequest("GroupDataMessageComposer"));

            response.AppendInteger(group.Id);
            response.AppendBool(true);
            response.AppendInteger(group.State);
            response.AppendString(group.Name);
            response.AppendString(group.Description);
            response.AppendString(group.Badge);
            response.AppendInteger(group.RoomId);
            response.AppendString(Yupi.GetGame().GetRoomManager().GenerateRoomData(@group.RoomId) == null
                ? "No room found.."
                : Yupi.GetGame().GetRoomManager().GenerateRoomData(@group.RoomId).Name);
            response.AppendInteger(@group.CreatorId == session.GetHabbo().Id
                ? 3
                : (group.Requests.ContainsKey(session.GetHabbo().Id)
                    ? 2
                    : (group.Members.ContainsKey(session.GetHabbo().Id) ? 1 : 0)));
            response.AppendInteger(group.Members.Count);
            response.AppendBool(session.GetHabbo().FavouriteGroup == group.Id);
            response.AppendString($"{dateTime2.Day.ToString("00")}-{dateTime2.Month.ToString("00")}-{dateTime2.Year}");
            response.AppendBool(group.CreatorId == session.GetHabbo().Id);
            response.AppendBool(group.Admins.ContainsKey(session.GetHabbo().Id));
            response.AppendString(Yupi.GetHabboById(@group.CreatorId) == null
                ? string.Empty
                : Yupi.GetHabboById(group.CreatorId).UserName);
            response.AppendBool(newWindow);
            response.AppendBool(group.AdminOnlyDeco == 0u);
            response.AppendInteger(group.Requests.Count);
            response.AppendBool(group.Forum.Id != 0);
            session.SendMessage(response);
        }
Exemplo n.º 20
0
 /// <summary>
 ///     Cancels the quest.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="message">The message.</param>
 internal void CancelQuest(GameClient session, ClientMessage message)
 {
     var quest = GetQuest(session.GetHabbo().CurrentQuestId);
     if (quest == null)
         return;
     using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
         queryReactor.RunFastQuery(string.Concat("DELETE FROM users_quests_data WHERE user_id = ",
             session.GetHabbo().Id, " AND quest_id = ", quest.Id, ";UPDATE users_stats SET quest_id=0 WHERE id=",
             session.GetHabbo().Id));
     session.GetHabbo().CurrentQuestId = 0;
     session.SendMessage(QuestAbortedComposer.Compose());
     GetList(session, null);
 }
Exemplo n.º 21
0
        /// <summary>
        ///     Removes the badge.
        /// </summary>
        /// <param name="badge">The badge.</param>
        /// <param name="session">The session.</param>
        internal void RemoveBadge(string badge, GameClient session)
        {
            if (!HasBadge(badge))
                return;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery("DELETE FROM users_badges WHERE badge_id = @badge AND user_id = " +
                                      _userId);

                queryReactor.AddParameter("badge", badge);
                queryReactor.RunQuery();
            }

            BadgeList.Remove(GetBadge(badge));
            session.SendMessage(Serialize());
        }
Exemplo n.º 22
0
        internal static void MatchingPollResults(GameClient client, Poll poll)
        {
            Room room = client.GetHabbo().CurrentRoom;
            if (poll == null || poll.Type != PollType.Matching || room == null)
                return;

            HashSet<RoomUser> users = room.GetRoomUserManager().GetRoomUsers();

            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(1000);
                foreach (RoomUser roomUser in users)
                {
                    Habbo user = Yupi.GetHabboById(roomUser.UserId);
                    if (user.AnsweredPool)
                    {
                        ServerMessage result =
                            new ServerMessage(LibraryParser.OutgoingRequest("MatchingPollResultMessageComposer"));
                        result.AppendInteger(poll.Id);
                        result.AppendInteger(2);
                        result.AppendString("0");
                        result.AppendInteger(poll.AnswersNegative);
                        result.AppendString("1");
                        result.AppendInteger(poll.AnswersPositive);
                        client.SendMessage(result);
                    }
                }
            }

            foreach (RoomUser roomUser in users)
                Yupi.GetHabboById(roomUser.UserId).AnsweredPool = false;
        }
Exemplo n.º 23
0
        /// <summary>
        ///     Sends the super notif.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="notice">The notice.</param>
        /// <param name="picture">The picture.</param>
        /// <param name="client">The client.</param>
        /// <param name="link">The link.</param>
        /// <param name="linkTitle">The link title.</param>
        /// <param name="broadCast">if set to <c>true</c> [broad cast].</param>
        /// <param name="Event">if set to <c>true</c> [event].</param>
        internal void SendSuperNotif(string title, string notice, string picture, GameClient client, string link,
            string linkTitle, bool broadCast, bool Event)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));

            serverMessage.AppendString(picture);
            serverMessage.AppendInteger(4);
            serverMessage.AppendString("title");
            serverMessage.AppendString(title);
            serverMessage.AppendString("message");

            if (broadCast)
                if (Event)
                {
                    string text1 = Yupi.GetLanguage().GetVar("ha_event_one");
                    string text2 = Yupi.GetLanguage().GetVar("ha_event_two");
                    string text3 = Yupi.GetLanguage().GetVar("ha_event_three");
                    serverMessage.AppendString(
                        $"<b>{text1} {client.GetHabbo().CurrentRoom.RoomData.Owner}!</b>\r\n {text2} .\r\n<b>{text3}</b>\r\n{notice}");
                }
                else
                {
                    string text4 = Yupi.GetLanguage().GetVar("ha_title");
                    serverMessage.AppendString(string.Concat("<b>" + text4 + "</b>\r\n", notice, "\r\n- <i>",
                        client.GetHabbo().UserName, "</i>"));
                }
            else
                serverMessage.AppendString(notice);

            if (link != string.Empty)
            {
                serverMessage.AppendString("linkUrl");
                serverMessage.AppendString(link);
                serverMessage.AppendString("linkTitle");
                serverMessage.AppendString(linkTitle);
            }
            else
            {
                serverMessage.AppendString("linkUrl");
                serverMessage.AppendString("event:");
                serverMessage.AppendString("linkTitle");
                serverMessage.AppendString("ok");
            }

            if (broadCast)
            {
                QueueBroadcaseMessage(serverMessage);

                return;
            }

            client.SendMessage(serverMessage);
        }
Exemplo n.º 24
0
        /// <summary>
        ///     Serializes the room data.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="session">The session.</param>
        /// <param name="isNotReload">if set to <c>true</c> [from view].</param>
        /// <param name="sendRoom">if set to <c>true</c> [send room].</param>
        /// <param name="show">if set to <c>true</c> [show].</param>
        internal void SerializeRoomData(ServerMessage message, GameClient session, bool isNotReload,
            bool? sendRoom = false, bool show = true)
        {
            Room room = Yupi.GetGame().GetRoomManager().GetRoom(session.GetHabbo().CurrentRoomId);

            message.Init(LibraryParser.OutgoingRequest("RoomDataMessageComposer"));
            message.AppendBool(show); //flatId
            Serialize(message, true, !isNotReload);
            message.AppendBool(isNotReload);
            message.AppendBool(Yupi.GetGame().GetNavigator() != null &&
                               Yupi.GetGame().GetNavigator().GetPublicItem(Id) != null); // staffPick
            message.AppendBool(!isNotReload || session.GetHabbo().HasFuse("fuse_mod")); // bypass bell, pass ...
            message.AppendBool(room != null && room.RoomMuted); //roomMuted
            message.AppendInteger(WhoCanMute);
            message.AppendInteger(WhoCanKick);
            message.AppendInteger(WhoCanBan);
            message.AppendBool(room != null && room.CheckRights(session, true));
            message.AppendInteger(ChatType);
            message.AppendInteger(ChatBalloon);
            message.AppendInteger(ChatSpeed);
            message.AppendInteger(ChatMaxDistance);
            message.AppendInteger(ChatFloodProtection);
            if (sendRoom == null) return;

            if (sendRoom.Value)
            {
                if (Yupi.GetGame().GetRoomManager().GetRoom(Id) != null)
                    Yupi.GetGame().GetRoomManager().GetRoom(Id).SendMessage(message);
            }
            else session.SendMessage(message);
        }
Exemplo n.º 25
0
        public static void SaveWired(GameClient session, RoomItem item, ClientMessage request)
        {
            if (item == null || !item.IsWired)
                return;

            Room room = item.GetRoom();

            WiredHandler wiredHandler = room?.GetWiredHandler();

            if (wiredHandler == null)
                return;

            switch (item.GetBaseItem().InteractionType)
            {
                case Interaction.TriggerTimer:
                {
                    request.GetInteger();
                    IWiredItem wired = wiredHandler.GetWired(item);
                    int delay = request.GetInteger()*500;
                    wired.Delay = delay;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.TriggerRoomEnter:
                {
                    request.GetInteger();
                    string otherString = request.GetString();
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.OtherString = otherString;
                    wiredHandler.ReloadWired(wired);
                    break;
                }

                case Interaction.TriggerLongRepeater:
                {
                    request.GetInteger();
                    int delay = request.GetInteger()*5000;
                    IWiredItem wired2 = wiredHandler.GetWired(item);
                    wired2.Delay = delay;
                    wiredHandler.ReloadWired(wired2);
                    break;
                }

                case Interaction.TriggerRepeater:
                {
                    request.GetInteger();
                    int delay = request.GetInteger()*500;
                    IWiredItem wired2 = wiredHandler.GetWired(item);
                    wired2.Delay = delay;
                    wiredHandler.ReloadWired(wired2);
                    break;
                }
                case Interaction.TriggerOnUserSay:
                {
                    request.GetInteger();
                    int num = request.GetInteger();
                    string otherString2 = request.GetString();
                    IWiredItem wired3 = wiredHandler.GetWired(item);
                    wired3.OtherString = otherString2;
                    wired3.OtherBool = num == 1;
                    wiredHandler.ReloadWired(wired3);
                    break;
                }
                case Interaction.TriggerStateChanged:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    int num2 = request.GetInteger();
                    IWiredItem wired4 = wiredHandler.GetWired(item);
                    wired4.Delay = num2*500;
                    wired4.Items = furniItems;
                    wiredHandler.ReloadWired(wired4);
                    break;
                }
                case Interaction.TriggerWalkOnFurni:
                case Interaction.ActionChase:
                case Interaction.ActionResetTimer:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems2 = GetFurniItems(request, room);
                    int num3 = request.GetInteger();
                    IWiredItem wired5 = wiredHandler.GetWired(item);
                    wired5.Delay = num3*500;
                    wired5.Items = furniItems2;
                    wiredHandler.ReloadWired(wired5);
                    break;
                }

                case Interaction.TriggerWalkOffFurni:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems3 = GetFurniItems(request, room);
                    int num4 = request.GetInteger();
                    IWiredItem wired6 = wiredHandler.GetWired(item);
                    wired6.Delay = num4*500;
                    wired6.Items = furniItems3;
                    wiredHandler.ReloadWired(wired6);
                    break;
                }
                case Interaction.ActionMoveRotate:
                case Interaction.ActionMoveToDir:
                {
                    request.GetInteger();
                    int dir = request.GetInteger();
                    int rot = request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems4 = GetFurniItems(request, room);
                    int delay = request.GetInteger();
                    IWiredItem wired7 = wiredHandler.GetWired(item);
                    wired7.Items = furniItems4;
                    wired7.Delay = delay*500;
                    wired7.OtherString = $"{dir};{rot}";
                    wiredHandler.ReloadWired(wired7);
                    break;
                }
                case Interaction.ActionShowMessage:
                case Interaction.ActionKickUser:
                {
                    request.GetInteger();
                    string otherString3 = request.GetString();
                    IWiredItem wired8 = wiredHandler.GetWired(item);
                    wired8.OtherString = otherString3;
                    wiredHandler.ReloadWired(wired8);
                    break;
                }
                case Interaction.ActionTeleportTo:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems5 = GetFurniItems(request, room);
                    int num8 = request.GetInteger();
                    IWiredItem wired9 = wiredHandler.GetWired(item);
                    wired9.Items = furniItems5;
                    wired9.Delay = num8*500;
                    wiredHandler.ReloadWired(wired9);
                    break;
                }
                case Interaction.ActionToggleState:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems6 = GetFurniItems(request, room);
                    int num9 = request.GetInteger();
                    IWiredItem wired10 = wiredHandler.GetWired(item);
                    wired10.Items = furniItems6;
                    wired10.Delay = num9*500;
                    wiredHandler.ReloadWired(wired10);
                    break;
                }
                case Interaction.ActionGiveReward:
                {
                    if (!session.GetHabbo().HasFuse("fuse_use_superwired"))
                        return;

                    request.GetInteger();
                    int often = request.GetInteger();
                    bool unique = request.GetIntegerAsBool();
                    int limit = request.GetInteger();
                    request.GetInteger();
                    string extrainfo = request.GetString();
                    List<RoomItem> furniItems7 = GetFurniItems(request, room);
                    IWiredItem wired11 = wiredHandler.GetWired(item);
                    wired11.Items = furniItems7;
                    wired11.Delay = 0;
                    wired11.OtherBool = unique;
                    wired11.OtherString = extrainfo;
                    wired11.OtherExtraString = often.ToString();
                    wired11.OtherExtraString2 = limit.ToString();
                    wiredHandler.ReloadWired(wired11);
                    break;
                }
                case Interaction.ActionMuteUser:
                {
                    request.GetInteger();
                    int minutes = request.GetInteger()*500;
                    string message = request.GetString();
                    List<RoomItem> furniItems7 = GetFurniItems(request, room);
                    IWiredItem wired11 = wiredHandler.GetWired(item);
                    wired11.Items = furniItems7;
                    wired11.Delay = minutes;
                    wired11.OtherBool = false;
                    wired11.OtherString = message;
                    wiredHandler.ReloadWired(wired11);
                    break;
                }
                case Interaction.TriggerScoreAchieved:
                {
                    request.GetInteger();
                    int pointsRequired = request.GetInteger();

                    IWiredItem wired11 = wiredHandler.GetWired(item);
                    wired11.Delay = 0;
                    wired11.OtherString = pointsRequired.ToString();
                    wiredHandler.ReloadWired(wired11);
                    break;
                }

                case Interaction.ConditionItemsMatches:
                case Interaction.ConditionItemsDontMatch:
                case Interaction.ActionPosReset:
                {
                    request.GetInteger();
                    bool actualExtraData = request.GetIntegerAsBool();
                    bool actualRot = request.GetIntegerAsBool();
                    bool actualPosition = request.GetIntegerAsBool();

                    string booleans = $"{actualExtraData},{actualRot},{actualPosition}".ToLower();

                    request.GetString();
                    List<RoomItem> items = GetFurniItems(request, room);

                    int delay = request.GetInteger()*500;
                    IWiredItem wiry = wiredHandler.GetWired(item);

                    string dataToSave = string.Empty;
                    string extraStringForWi = string.Empty;

                    foreach (RoomItem aItem in items)
                    {
                        if (aItem.GetBaseItem().InteractionType == Interaction.Dice)
                        {
                            // Why have a RETURN here?
                            dataToSave += string.Format("0|0|0|0,0,0", aItem.Id, aItem.ExtraData, aItem.Rot, aItem.X,
                                aItem.Y, aItem.Z);
                            extraStringForWi +=
                                $"{aItem.Id},{(actualExtraData ? aItem.ExtraData : "N")},{(actualRot ? aItem.Rot.ToString() : "N")},{(actualPosition ? aItem.X.ToString() : "N")},{(actualPosition ? aItem.Y.ToString() : "N")}";

                            return;
                        }

                        dataToSave += $"{aItem.Id}|{aItem.ExtraData}|{aItem.Rot}|{aItem.X},{aItem.Y},{aItem.Z}";
                        extraStringForWi +=
                            $"{aItem.Id},{(actualExtraData ? aItem.ExtraData : "N")},{(actualRot ? aItem.Rot.ToString() : "N")},{(actualPosition ? aItem.X.ToString() : "N")},{(actualPosition ? aItem.Y.ToString() : "N")}";

                        if (aItem == items.Last())
                            continue;

                        dataToSave += "/";
                        extraStringForWi += ";";
                    }

                    wiry.Items = items;
                    wiry.Delay = delay;
                    wiry.OtherBool = true;
                    wiry.OtherString = booleans;
                    wiry.OtherExtraString = dataToSave;
                    wiry.OtherExtraString2 = extraStringForWi;
                    wiredHandler.ReloadWired(wiry);
                    break;
                }

                case Interaction.ConditionGroupMember:
                case Interaction.ConditionNotGroupMember:
                case Interaction.TriggerCollision:
                {
                    break;
                }

                case Interaction.ConditionHowManyUsersInRoom:
                case Interaction.ConditionNegativeHowManyUsers:
                {
                    request.GetInteger();
                    int minimum = request.GetInteger();
                    int maximum = request.GetInteger();

                    string ei = $"{minimum},{maximum}";
                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    wired12.Items = new List<RoomItem>();
                    wired12.OtherString = ei;
                    wiredHandler.ReloadWired(wired12);
                    break;
                }

                case Interaction.ConditionUserNotWearingEffect:
                case Interaction.ConditionUserWearingEffect:
                {
                    request.GetInteger();
                    int effect = request.GetInteger();
                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    wired12.Items = new List<RoomItem>();
                    wired12.OtherString = effect.ToString();
                    wiredHandler.ReloadWired(wired12);
                    break;
                }

                case Interaction.ConditionUserWearingBadge:
                case Interaction.ConditionUserNotWearingBadge:
                case Interaction.ConditionUserHasFurni:
                {
                    request.GetInteger();
                    string badge = request.GetString();
                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    wired12.Items = new List<RoomItem>();
                    wired12.OtherString = badge;
                    wiredHandler.ReloadWired(wired12);
                    break;
                }

                case Interaction.ConditionDateRangeActive:
                {
                    request.GetInteger();

                    int startDate = request.GetInteger();
                    int endDate = request.GetInteger();

                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    wired12.Items = new List<RoomItem>();
                    wired12.OtherString = $"{startDate},{endDate}";

                    if (startDate == 0)
                    {
                        wired12.OtherString = string.Empty;
                        session.SendNotif(Yupi.GetLanguage().GetVar("user_wired_con_date_range"));
                    }

                    wiredHandler.ReloadWired(wired12);
                    break;
                }

                case Interaction.ConditionFurnisHaveUsers:
                case Interaction.ConditionTriggerOnFurni:
                case Interaction.ConditionFurniTypeMatches:
                case Interaction.ConditionFurnisHaveNotUsers:
                case Interaction.ConditionTriggererNotOnFurni:
                case Interaction.ConditionFurniTypeDontMatch:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    IWiredItem wired12 = wiredHandler.GetWired(item);

                    wired12.Items = furniItems;
                    wiredHandler.ReloadWired(wired12);
                    break;
                }
                case Interaction.ConditionFurniHasFurni:
                case Interaction.ConditionFurniHasNotFurni:
                {
                    request.GetInteger();
                    bool allItems = request.GetIntegerAsBool();
                    request.GetString();

                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    IWiredItem wired = wiredHandler.GetWired(item);

                    wired.OtherBool = allItems;
                    wired.Items = furniItems;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionGiveScore:
                {
                    request.GetInteger();
                    int scoreToGive = request.GetInteger();
                    int maxTimesPerGame = request.GetInteger();

                    string newExtraInfo = $"{scoreToGive},{maxTimesPerGame}";

                    List<RoomItem> furniItems8 = GetFurniItems(request, room);
                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    wired12.Items = furniItems8;
                    wired12.OtherString = newExtraInfo;
                    wiredHandler.ReloadWired(wired12);
                    break;
                }
                case Interaction.ActionJoinTeam:
                {
                    request.GetInteger();
                    int team = request.GetInteger();
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.Delay = team*500;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotTalk:
                {
                    request.GetInteger();
                    bool type = request.GetIntegerAsBool();
                    string[] data = request.GetString().Split((char) 9);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.OtherBool = type;
                    wired.OtherString = data[0];
                    wired.OtherExtraString = data[1];
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotClothes:
                {
                    request.GetInteger();
                    string[] data = request.GetString().Split((char) 9);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.OtherString = data[0];
                    wired.OtherExtraString = data[1];
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotTeleport:
                {
                    request.GetInteger();
                    string botName = request.GetString();
                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.Items = furniItems;
                    wired.OtherString = botName;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotGiveHanditem:
                {
                    request.GetInteger();
                    int handitem = request.GetInteger();
                    string botName = request.GetString();
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.OtherString = botName;
                    wired.Delay = handitem*500;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotMove:
                {
                    request.GetInteger();
                    string botName = request.GetString();
                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.Items = furniItems;
                    wired.OtherString = botName;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionCallStacks:
                {
                    request.GetInteger();
                    request.GetString();
                    List<RoomItem> furniItems = GetFurniItems(request, room);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    int num = request.GetInteger();
                    wired.Items = furniItems;
                    wired.Delay = num*500;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ActionBotTalkToAvatar:
                {
                    request.GetInteger();
                    bool type = request.GetIntegerAsBool();
                    string[] data = request.GetString().Split((char) 9);
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.OtherBool = type;
                    wired.OtherString = data[0];
                    wired.OtherExtraString = data[1];
                    wiredHandler.ReloadWired(wired);
                    break;
                }
                case Interaction.ConditionTimeMoreThan:
                case Interaction.ConditionTimeLessThan:
                {
                    request.GetInteger();
                    int time = request.GetInteger();
                    IWiredItem wired12 = wiredHandler.GetWired(item);
                    Console.WriteLine(time);
                    wired12.Delay = time*500;
                    wiredHandler.ReloadWired(wired12);
                    break;
                }
                case Interaction.ConditionUserHasHanditem:
                {
                    request.GetInteger();
                    int handitem = request.GetInteger();
                    IWiredItem wired = wiredHandler.GetWired(item);
                    wired.Delay = handitem*500;
                    wiredHandler.ReloadWired(wired);
                    break;
                }
            }

            session.SendMessage(new ServerMessage(LibraryParser.OutgoingRequest("SaveWiredMessageComposer")));
        }
Exemplo n.º 26
0
        /// <summary>
        ///     Progresses the user quest.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="questType">Type of the quest.</param>
        /// <param name="eventData">The event data.</param>
        internal void ProgressUserQuest(GameClient session, QuestType questType, uint eventData = 0u)
        {
            if (session == null || session.GetHabbo() == null || session.GetHabbo().CurrentQuestId <= 0u)
                return;
            var quest = GetQuest(session.GetHabbo().CurrentQuestId);
            if (quest == null || quest.GoalType != questType)
                return;
            var questProgress = session.GetHabbo().GetQuestProgress(quest.Id);
            var num = questProgress;
            var flag = false;

            {
                if (questType != QuestType.ExploreFindItem)
                    switch (questType)
                    {
                        case QuestType.StandOn:
                        case QuestType.GiveItem:
                            if (eventData != quest.GoalData)
                                return;
                            num = (int) quest.GoalData;
                            flag = true;
                            goto IL_DC;
                        case QuestType.GiveCoffee:
                        case QuestType.WaveReindeer:
                        case QuestType.XmasParty:
                        case QuestType.FurniMove:
                            num++;
                            if (num >= quest.GoalData)
                                flag = true;
                            goto IL_DC;
                    }
                if (eventData != quest.GoalData)
                    return;
                num = (int) quest.GoalData;
                flag = true;
                IL_DC:

                using (var queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.RunFastQuery(string.Concat("UPDATE users_quests_data SET progress = ", num,
                        " WHERE user_id = ", session.GetHabbo().Id, " AND quest_id =  ", quest.Id));
                    if (flag)
                        queryReactor.RunFastQuery(
                            $"UPDATE users_stats SET quest_id = 0 WHERE id = {session.GetHabbo().Id}");
                }

                session.GetHabbo().Quests[session.GetHabbo().CurrentQuestId] = num;
                session.SendMessage(QuestStartedComposer.Compose(session, quest));

                if (!flag)
                    return;
                session.GetHabbo().CurrentQuestId = 0;
                session.GetHabbo().LastQuestCompleted = quest.Id;
                session.SendMessage(QuestCompletedComposer.Compose(session, quest));
                session.GetHabbo().ActivityPoints += quest.Reward;
                session.GetHabbo().NotifyNewPixels(quest.Reward);
                session.GetHabbo().UpdateSeasonalCurrencyBalance();
                GetList(session, null);
            }
        }