Exemple #1
0
        internal static void SellItem(GameClient Session, UserItem Item, uint SellingPrice)
        {
            if (Item == null || SellingPrice > 10000 || !CanSellItem(Item))
            {
                Session.GetMessageHandler().GetResponse().Init(Outgoing.MarketConfirmPost);
                Session.GetMessageHandler().GetResponse().AppendInt32(2);
                Session.GetMessageHandler().SendResponse();
                return;
            }

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

            if (Item.mBaseItem.Type == 'i')
            {
                ItemType++;
            }

            using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT INTO catalog_marketplace_offers (item_id,user_id,asking_price,total_price,public_name,item_type,timestamp,extra_data) VALUES (" + Item.BaseItem + "," + Session.GetHabbo().Id + "," + SellingPrice + "," + TotalPrice + ",@public_name," + ItemType + "," + (OtanixEnvironment.GetUnixTimestamp() + 172800) + ",@extra_data)");
                dbClient.addParameter("public_name", Furnidata.GetPublicNameByItemName(Item.mBaseItem.Name));
                dbClient.addParameter("extra_data", Item.ExtraData);
                dbClient.runQuery();
            }

            Session.GetMessageHandler().GetResponse().Init(Outgoing.MarketConfirmPost);
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().SendResponse();

            Session.GetHabbo().GetInventoryComponent().RemoveItem(Item.Id, true);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();
        }
Exemple #2
0
        internal void DeliverBalloonRandomItem(RoomUser User, Room Room, RoomItem Item)
        {
            if (!Piñatas.ContainsKey(Item.GetBaseItem().ItemId))
            {
                return;
            }

            PiñataItem piñata;

            Piñatas.TryGetValue(Item.GetBaseItem().ItemId, out piñata);
            if (piñata == null)
            {
                return;
            }

            // backup de las variables:
            int X = Item.GetX, Y = Item.GetY;

            // Borramos la piñata.
            Item.ExtraData = "1";
            Item.UpdateState();
            Room.GetRoomItemHandler().RemoveFurniture(User.GetClient(), Item);

            uint itemID = EmuSettings.FIRST_BALLOON_PRESENT_ID + (uint)(new Random().Next(0, (int)(EmuSettings.LAST_BALLOON_PRESENT_ID - EmuSettings.FIRST_BALLOON_PRESENT_ID)));

            uint randomId = piñata.rewards[new Random().Next(0, piñata.rewards.Count - 1)];
            Item rareItem = OtanixEnvironment.GetGame().GetItemManager().GetItem(randomId);

            if (rareItem == null)
            {
                return;
            }

            Item.BaseItem  = itemID;
            Item.ExtraData = Item.OwnerId + ";0;" + Furnidata.GetPublicNameByItemName(rareItem.Name);
            Item.SetState(X, Y);

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE items SET base_id = '" + itemID + "' WHERE item_id = " + Item.Id);

                dbClient.setQuery("UPDATE items_extradata SET data = @extradata WHERE item_id = " + Item.Id);
                dbClient.addParameter("extradata", rareItem.Name);
                dbClient.runQuery();

                dbClient.setQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + Item.Id + "," + randomId + "," + 1 + ",@extra_data)");
                dbClient.addParameter("extra_data", "");
                dbClient.runQuery();
            }

            if (!Room.GetRoomItemHandler().SetFloorItem(User.GetClient(), Item, Item.GetX, Item.GetY, Item.Rot, true, false, true, false, true))
            {
                User.GetClient().SendNotif("Ha ocurrido un error al crear la piñata!");
                return;
            }
        }
        public void loadFurniXml()
        {
            string text = File.ReadAllText(@"Content/furnidata.xml");
            var    sr   = new System.IO.StringReader(text);
            var    xs   = new XmlSerializer(typeof(Furnidata));

            var       result    = xs.Deserialize(sr);
            Furnidata furnidata = (Furnidata)result;

            foreach (Furnitype type in furnidata.roomitemtypes)
            {
                if (!_furnitypes.ContainsKey(type.id))
                {
                    _furnitypes.Add(type.id, type);
                }
            }
        }
Exemple #4
0
        internal void ContinueLoading()
        {
            DateTime Start;
            TimeSpan TimeUsed;

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                EmuSettings.Initialize(dbClient);

                Start = DateTime.Now;
                Ranks.LoadMaxRankId(dbClient);
                Catalog.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Catacache -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Filter.Filter.Initialize();
                Filter.BlackWordsManager.Load(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Filtro -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                BanManager.LoadBans(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de Ban -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                newsManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Notícia -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ItemManager.LoadItems(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de item -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Furnidata.Initialize();
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de Furnidata -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PromotionalBadgesManager.loadPromotionalBadges(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Emblemas promocionais -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                RoleManager.LoadRanks(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de papel -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Navigator.Initialize(dbClient);
                NewNavigatorManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Navegador -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                RoomManager.LoadModels(dbClient);
                RoomManager.InitVotedRooms(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente do quarto -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                AchievementManager.Initialize(dbClient);
                questManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de realização -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ModerationTool.LoadMessagePresets(dbClient);
                ModerationTool.LoadModActions(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Ferramenta de moderação-> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PetRace.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Sistema de estimação-> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PetOrders.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Ordens para animais -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                GuildsPartsManager.InitGroups(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Elementos dos grupos -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Catalog.InitCache();
                CatalogPremium.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de catálogo -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                SongManager.Initialize();
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de som -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                youtubeManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Youtube TV Manager -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                piñataManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente Piñata -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                talentManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de talentos -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                TargetedOfferManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente da oferta direta -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                CraftableProductsManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de Produtos Crafáveis -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ClothingManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Gerente de vestuário-> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PrisaoManager.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Usuários presos -> PRONTO! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                LandingTopUsersManager.Initialize(dbClient);
                LandingTopUsersManager.Load();
                giftManager.init(dbClient);
                SpyChatMessage.Initialize();
                StaffChat.Initialize(dbClient);
                BonusManager.Initialize(dbClient);
                roomRankConfig.Initialize();

                Start = DateTime.Now;
                DatabaseCleanup(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("[Otanix] @ Database -> Limpeza realizada! (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
            }

            StartGameLoop();

            Logging.WriteLine("[Otanix] @ Gerente de jogo -> PRONTO! ");
        }
Exemple #5
0
        internal void ContinueLoading()
        {
            DateTime Start;
            TimeSpan TimeUsed;

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                EmuSettings.Initialize(dbClient);

                Start = DateTime.Now;
                Ranks.LoadMaxRankId(dbClient);
                Catalog.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Catalog Cache -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Filter.Filter.Initialize();
                Filter.BlackWordsManager.Load(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Filter -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                BanManager.LoadBans(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Ban Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                newsManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("News Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ItemManager.LoadItems(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Item Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Furnidata.Initialize();
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Furnidata -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PromotionalBadgesManager.loadPromotionalBadges(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Promotional Badges Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                RoleManager.LoadRanks(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Ranks -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Navigator.Initialize(dbClient);
                NewNavigatorManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Navigator -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                RoomManager.LoadModels(dbClient);
                RoomManager.InitVotedRooms(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Room Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                AchievementManager.Initialize(dbClient);
                questManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Quest Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ModerationTool.LoadMessagePresets(dbClient);
                ModerationTool.LoadModActions(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Moderation Tool -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PetRace.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Pet Race -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PetOrders.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Pet Orders -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                GuildsPartsManager.InitGroups(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Guilds Parts Manager-> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                Catalog.InitCache();
                CatalogPremium.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Catalog Manager -> PRONTO (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                SongManager.Initialize();
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Song Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                youtubeManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Youtube TV Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                piñataManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Piñata Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                talentManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Talent Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                TargetedOfferManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Targeted Offer Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                CraftableProductsManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Craftable Products Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                ClothingManager.Initialize(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Clothing Manager-> PRONTO (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                Start = DateTime.Now;
                PrisaoManager.Init(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Prison Manager -> READY (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");

                LandingTopUsersManager.Initialize(dbClient);
                LandingTopUsersManager.Load();
                giftManager.init(dbClient);
                SpyChatMessage.Initialize();
                StaffChat.Initialize(dbClient);
                BonusManager.Initialize(dbClient);
                roomRankConfig.Initialize();

                Start = DateTime.Now;
                DatabaseCleanup(dbClient);
                TimeUsed = DateTime.Now - Start;
                Logging.WriteLine("Database -> Cleanup Done (" + TimeUsed.Seconds + " s, " + TimeUsed.Milliseconds + " ms)");
            }

            StartGameLoop();

            Logging.WriteLine("Game Loop -> READY ");
        }