Esempio n. 1
0
        public static void OpenExtrabox(GameClient Session, Item Present, Room Room)
        {
            CatalogPage Page   = null;
            int         PageId = 0;

            if (ButterflyEnvironment.GetRandomNumber(1, 1000) == 1000) //Ultra rare
            {
                PageId = 84641;
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 150) == 150) //Extra rare
            {
                PageId = 98747;
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 75) == 75) //Pièce Win-win
            {
                PageId = 456465;
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 150) == 150) //WibboPoint
            {
                PageId = 15987;
            }
            else
            {
                PageId = 894948; //Rare
            }


            ButterflyEnvironment.GetGame().GetCatalog().TryGetPage(PageId, out Page);
            if (Page == null)
            {
                Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.error", Session.Langue));
                return;
            }

            ItemData LotData = Page.Items.ElementAt(ButterflyEnvironment.GetRandomNumber(0, Page.Items.Count - 1)).Value.Data;

            if (LotData == null)
            {
                Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.error", Session.Langue));
                return;
            }

            Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id);

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("UPDATE items SET base_item = @baseid WHERE id = " + Present.Id);
                queryreactor.AddParameter("baseid", LotData.Id);
                queryreactor.RunQuery();
            }

            string FurniType = Present.GetBaseItem().Type.ToString().ToLower();

            Present.BaseItem = LotData.Id;
            Present.ResetBaseItem();

            bool ItemIsInRoom = true;

            if (Present.Data.Type == 's')
            {
                if (!Room.GetRoomItemHandler().SetFloorItem(Session, Present, Present.GetX, Present.GetY, Present.Rotation, true, false, true))
                {
                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = @itemId LIMIT 1");
                        dbClient.AddParameter("itemId", Present.Id);
                        dbClient.RunQuery();
                    }

                    ItemIsInRoom = false;
                }
            }
            else
            {
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = @itemId LIMIT 1");
                    dbClient.AddParameter("itemId", Present.Id);
                    dbClient.RunQuery();
                }

                ItemIsInRoom = false;
            }

            Session.SendPacket(new OpenGiftComposer(Present.Data, Present.ExtraData, Present, ItemIsInRoom));

            if (!ItemIsInRoom)
            {
                Session.GetHabbo().GetInventoryComponent().TryAddItem(Present);
            }
        }
Esempio n. 2
0
        public static void OpenLegendBox(GameClient Session, Item Present, Room Room)
        {
            CatalogPage Page      = null;
            int         PageId    = 0;
            string      BadgeCode = "";
            string      LotType   = "";
            int         ForceItem = 0;

            if (ButterflyEnvironment.GetRandomNumber(1, 100) == 100) //Legendaire
            {
                PageId  = 14514;
                LotType = "Légendaire";
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 100) == 100) //Royal
            {
                PageId    = 584545;
                LotType   = "Royal";
                ForceItem = 37951979;
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 50) == 50) //Royal
            {
                PageId    = 584545;
                LotType   = "Royal";
                ForceItem = 70223722;
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 15) == 15) //Ultra rare
            {
                PageId  = 84641;
                LotType = "Ultra";
            }
            else if (ButterflyEnvironment.GetRandomNumber(1, 5) == 5) //Royal
            {
                PageId    = 584545;
                LotType   = "Royal";
                ForceItem = 52394359;
            }
            else
            {
                PageId  = 98747;
                LotType = "Extra";
            }


            int         PageBadgeId = 841878;
            CatalogPage PageBadge   = null;

            ButterflyEnvironment.GetGame().GetCatalog().TryGetPage(PageBadgeId, out PageBadge);
            if (PageBadge == null)
            {
                return;
            }

            foreach (KeyValuePair <int, CatalogItem> Item in PageBadge.Items.OrderBy(a => Guid.NewGuid()).ToList())
            {
                if (Session.GetHabbo().GetBadgeComponent().HasBadge(Item.Value.Badge))
                {
                    continue;
                }

                BadgeCode = Item.Value.Badge;
                break;
            }

            ButterflyEnvironment.GetGame().GetCatalog().TryGetPage(PageId, out Page);
            if (Page == null)
            {
                Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.error", Session.Langue));
                return;
            }

            ItemData LotData = null;

            if (ForceItem == 0)
            {
                LotData = Page.Items.ElementAt(ButterflyEnvironment.GetRandomNumber(0, Page.Items.Count - 1)).Value.Data;
            }
            else
            {
                LotData = Page.GetItem(ForceItem).Data;
            }

            if (LotData == null)
            {
                Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("notif.error", Session.Langue));
                return;
            }

            int Credits = ButterflyEnvironment.GetRandomNumber(100, 10000) * 1000;

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

            int WinWin = ButterflyEnvironment.GetRandomNumber(100, 1000);

            Session.GetHabbo().AchievementPoints += WinWin;

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.RunQuery("UPDATE user_stats SET AchievementScore = AchievementScore + '" + WinWin + "' WHERE id = '" + Session.GetHabbo().Id + "'");
            }

            Session.SendPacket(new AchievementScoreComposer(Session.GetHabbo().AchievementPoints));
            RoomUser roomUserByHabbo = Room.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id);

            if (roomUserByHabbo != null)
            {
                Session.SendPacket(new UserChangeComposer(roomUserByHabbo, true));
                Room.SendPacket(new UserChangeComposer(roomUserByHabbo, false));
            }

            if (!string.IsNullOrEmpty(BadgeCode))
            {
                Session.GetHabbo().GetBadgeComponent().GiveBadge(BadgeCode, true);
                Session.SendPacket(new ReceiveBadgeComposer(BadgeCode));
            }

            if (roomUserByHabbo != null)
            {
                roomUserByHabbo.SendWhisperChat(string.Format(ButterflyEnvironment.GetLanguageManager().TryGetValue("item.legendboxlot", Session.Langue), Credits, WinWin, BadgeCode, LotType));
            }

            Room.GetRoomItemHandler().RemoveFurniture(Session, Present.Id);

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("UPDATE items SET base_item = @baseid WHERE id = " + Present.Id);
                queryreactor.AddParameter("baseid", LotData.Id);
                queryreactor.RunQuery();
            }
            string FurniType = Present.GetBaseItem().Type.ToString().ToLower();

            Present.BaseItem = LotData.Id;
            Present.ResetBaseItem();

            bool ItemIsInRoom = true;

            if (Present.Data.Type == 's')
            {
                if (!Room.GetRoomItemHandler().SetFloorItem(Session, Present, Present.GetX, Present.GetY, Present.Rotation, true, false, true))
                {
                    using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = @itemId LIMIT 1");
                        dbClient.AddParameter("itemId", Present.Id);
                        dbClient.RunQuery();
                    }

                    ItemIsInRoom = false;
                }
            }
            else
            {
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `items` SET `room_id` = '0' WHERE `id` = @itemId LIMIT 1");
                    dbClient.AddParameter("itemId", Present.Id);
                    dbClient.RunQuery();
                }

                ItemIsInRoom = false;
            }

            Session.SendPacket(new OpenGiftComposer(Present.Data, Present.ExtraData, Present, ItemIsInRoom));

            if (!ItemIsInRoom)
            {
                Session.GetHabbo().GetInventoryComponent().TryAddItem(Present);
            }
        }
Esempio n. 3
0
        public static void GenerateExtradata(Item Item, ServerPacket Message)
        {
            switch (Item.GetBaseItem().InteractionType)
            {
            default:
                Message.WriteInteger(1);
                Message.WriteInteger(0);
                Message.WriteString((Item.GetBaseItem().InteractionType != InteractionType.TONER && Item.GetBaseItem().InteractionType != InteractionType.fbgate) ? Item.ExtraData : string.Empty);
                break;

            case InteractionType.WALLPAPER:
                Message.WriteInteger(2);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);

                break;

            case InteractionType.FLOOR:
                Message.WriteInteger(3);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);
                break;

            case InteractionType.LANDSCAPE:
                Message.WriteInteger(4);
                Message.WriteInteger(0);
                Message.WriteString(Item.ExtraData);
                break;

            case InteractionType.GUILD_ITEM:
            case InteractionType.GUILD_GATE:
                Group Group = null;
                if (!ButterflyEnvironment.GetGame().GetGroupManager().TryGetGroup(Item.GroupId, out Group))
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString(Item.ExtraData);
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(2);
                    Message.WriteInteger(5);
                    Message.WriteString(Item.ExtraData.Split(new char[1] {
                        ';'
                    })[0]);
                    Message.WriteString(Group.Id.ToString());
                    Message.WriteString(Group.Badge);
                    Message.WriteString(ButterflyEnvironment.GetGame().GetGroupManager().GetColourCode(Group.Colour1, true));
                    Message.WriteString(ButterflyEnvironment.GetGame().GetGroupManager().GetColourCode(Group.Colour2, false));
                }
                break;

            case InteractionType.highscore:
            case InteractionType.highscorepoints:
                Message.WriteInteger(0);

                Message.WriteInteger(6);     //Type

                Message.WriteString(Item.ExtraData);
                Message.WriteInteger(2);     //Type de victoire
                Message.WriteInteger(0);     //Type de duré


                Message.WriteInteger((Item.Scores.Count > 20) ? 20 : Item.Scores.Count);     //count

                foreach (KeyValuePair <string, int> score in Item.Scores.OrderByDescending(x => x.Value).Take(20))
                {
                    Message.WriteInteger(score.Value); //score
                    Message.WriteInteger(1);           //(score.Key.Count); //count
                    //foreach(string UsernameScore in score.Key)
                    //Message.AppendString(UsernameScore);
                    Message.WriteString(score.Key);
                }
                break;

            case InteractionType.LOVELOCK:
                if (Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    string[] EData = Item.ExtraData.Split((char)5);
                    int      I     = 0;
                    Message.WriteInteger(0);
                    Message.WriteInteger(2);
                    Message.WriteInteger(EData.Length);
                    while (I < EData.Length)
                    {
                        Message.WriteString(EData[I]);
                        I++;
                    }
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString("0");
                }
                break;

            case InteractionType.crackable:
                Message.WriteInteger(0);

                Message.WriteInteger(7);     //Type

                int NombreClick = 0;
                int.TryParse(Item.ExtraData, out NombreClick);

                Message.WriteString(Item.ExtraData);
                Message.WriteInteger(NombreClick);                  //Nombre de click
                Message.WriteInteger(Item.GetBaseItem().Modes - 1); //Type de duré
                break;

            case InteractionType.adsbackground:
                if (!String.IsNullOrEmpty(Item.ExtraData))
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(1);

                    string ExtraDatabackground = "state" + Convert.ToChar(9) + "0" + Convert.ToChar(9) + Item.ExtraData;

                    ExtraDatabackground = ExtraDatabackground.Replace('=', Convert.ToChar(9));
                    Message.WriteInteger(ExtraDatabackground.Split(Convert.ToChar(9)).Length / 2);

                    for (int i = 0; i <= ExtraDatabackground.Split(Convert.ToChar(9)).Length - 1; i++)
                    {
                        string Data = ExtraDatabackground.Split(Convert.ToChar(9))[i];
                        Message.WriteString(Data);
                    }
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString("");
                }
                break;

            case InteractionType.EXTRABOX:
            {
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(4);
                Message.WriteString("MESSAGE");
                Message.WriteString("Bravo tu as reçu une ExtraBox ! Ouvre-là pour y découvrir ton lot");
                Message.WriteString("PURCHASER_NAME");
                Message.WriteString("Wibbo");
                Message.WriteString("PRODUCT_CODE");
                Message.WriteString("A1 KUMIANKKA");
                Message.WriteString("PURCHASER_FIGURE");
                Message.WriteString("");
            }
            break;

            case InteractionType.BADGEBOX:
            {
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(4);
                Message.WriteString("MESSAGE");
                Message.WriteString("Bravo tu as reçu une BadgeBox ! Ouvre-là pour y découvrir ton lot");
                Message.WriteString("PURCHASER_NAME");
                Message.WriteString("Wibbo");
                Message.WriteString("PRODUCT_CODE");
                Message.WriteString("A1 KUMIANKKA");
                Message.WriteString("PURCHASER_FIGURE");
                Message.WriteString("");
            }
            break;

            case InteractionType.LEGENDBOX:
            {
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(4);
                Message.WriteString("MESSAGE");
                Message.WriteString("Bravo tu as reçu une magnifique LegendBox ! Ouvre-là pour y décrouvrir tes lots !");
                Message.WriteString("PURCHASER_NAME");
                Message.WriteString("Wibbo");
                Message.WriteString("PRODUCT_CODE");
                Message.WriteString("A1 KUMIANKKA");
                Message.WriteString("PURCHASER_FIGURE");
                Message.WriteString("");
            }
            break;

            case InteractionType.GIFT:
            {
                if (!Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString(Item.ExtraData);
                }
                else
                {
                    string[] ExtraData = Item.ExtraData.Split(Convert.ToChar(5));
                    int      Style     = int.Parse(Item.ExtraData.Split(new char[1] {
                            '\x0005'
                        })[1]) * 1000 + int.Parse(Item.ExtraData.Split(new char[1] {
                            '\x0005'
                        })[2]);

                    Habbo Purchaser = ButterflyEnvironment.GetHabboById(int.Parse(Item.ExtraData.Split(new char[1] {
                            ';'
                        })[0]));
                    Message.WriteInteger(0);
                    Message.WriteInteger(1);
                    Message.WriteInteger(6);
                    Message.WriteString("EXTRA_PARAM");
                    Message.WriteString("");
                    Message.WriteString("MESSAGE");
                    Message.WriteString(Item.ExtraData.Split(new char[1] {
                            ';'
                        })[1].Split(new char[1] {
                            '\x0005'
                        })[0]);
                    Message.WriteString("PURCHASER_NAME");
                    Message.WriteString(Purchaser == null ? "" : Purchaser.Username);
                    Message.WriteString("PURCHASER_FIGURE");
                    Message.WriteString(Purchaser == null ? "" : Purchaser.Look);
                    Message.WriteString("PRODUCT_CODE");
                    Message.WriteString("A1 KUMIANKKA");
                    Message.WriteString("state");
                    Message.WriteString(Style.ToString());
                }
            }
            break;

            case InteractionType.MANNEQUIN:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(3);
                if (Item.ExtraData.Contains(";"))
                {
                    string[] Stuff = Item.ExtraData.Split(new char[1] {
                        ';'
                    });
                    Message.WriteString("GENDER");
                    Message.WriteString(Stuff[0].ToUpper() == "M" ? "M" : "F");
                    Message.WriteString("FIGURE");
                    Message.WriteString(Stuff[1]);
                    Message.WriteString("OUTFIT_NAME");
                    Message.WriteString(Stuff[2]);
                }
                else
                {
                    Message.WriteString("GENDER");
                    Message.WriteString("M");
                    Message.WriteString("FIGURE");
                    Message.WriteString("");
                    Message.WriteString("OUTFIT_NAME");
                    Message.WriteString("");
                }
                break;

            case InteractionType.TONER:
                if (Item.ExtraData.Contains(","))
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(5);
                    Message.WriteInteger(4);
                    Message.WriteInteger(Item.ExtraData.StartsWith("on") ? 1 : 0);
                    Message.WriteInteger(int.Parse(Item.ExtraData.Split(new char[1] {
                        ','
                    })[1]));
                    Message.WriteInteger(int.Parse(Item.ExtraData.Split(new char[1] {
                        ','
                    })[2]));
                    Message.WriteInteger(int.Parse(Item.ExtraData.Split(new char[1] {
                        ','
                    })[3]));
                }
                else
                {
                    Message.WriteInteger(0);
                    Message.WriteInteger(0);
                    Message.WriteString(string.Empty);
                }
                break;

            case InteractionType.BADGE_DISPLAY:
            case InteractionType.BADGE_TROC:
                Message.WriteInteger(0);
                Message.WriteInteger(2);
                Message.WriteInteger(4);

                if (Item.ExtraData.Contains(Convert.ToChar(9).ToString()))
                {
                    string[] BadgeData = Item.ExtraData.Split(Convert.ToChar(9));

                    Message.WriteString("0");          //No idea
                    Message.WriteString(BadgeData[0]); //Badge name
                    Message.WriteString(BadgeData[1]); //Owner
                    Message.WriteString(BadgeData[2]); //Date
                }
                else
                {
                    Message.WriteString("0");            //No idea
                    Message.WriteString(Item.ExtraData); //Badge name
                    Message.WriteString("");             //Owner
                    Message.WriteString("");             //Date
                }
                break;

            case InteractionType.tvyoutube:
                Message.WriteInteger(0);
                Message.WriteInteger(1);
                Message.WriteInteger(2);
                Message.WriteString("THUMBNAIL_URL");
                Message.WriteString((string.IsNullOrEmpty(Item.ExtraData)) ? "" : "https://cdn.wibbo.me/youtubethumbnail.php?videoid=" + Item.ExtraData);     //"https://i1.ytimg.com/vi/" + Item.ExtraData + "/default.jpg")
                Message.WriteString("VideoId");
                Message.WriteString(Item.ExtraData);
                break;
            }
        }