Example #1
0
        public static void PerformShutDown()
        {
            Console.Clear();
            log.Info("Server shutting down...");
            Console.Title = "HABBO EMULATOR: SHUTTING DOWN!";

            HabboEnvironment.GetGame().GetClientManager().SendMessage(new BroadcastMessageAlertComposer(HabboEnvironment.GetGame().GetLanguageLocale().TryGetValue("shutdown_alert")));
            GetGame().StopGameLoop();
            Thread.Sleep(2500);
            GetConnectionManager().Destroy();             //Stop listening.
            GetGame().GetPacketManager().UnregisterAll(); //Unregister the packets.
            GetGame().GetPacketManager().WaitForAllToComplete();
            GetGame().GetClientManager().CloseAll();      //Close all connections
            GetGame().GetRoomManager().Dispose();         //Stop the game loop.


            using (IQueryAdapter dbClient = _manager.GetQueryReactor())
            {
                dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`");
                dbClient.RunQuery("UPDATE `users` SET `online` = '0', `auth_ticket` = ''");
                dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'");
                dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'");
            }

            log.Info("Habbo Emulator has successfully shutdown.");

            Thread.Sleep(1000);
            Environment.Exit(0);
        }
Example #2
0
        public static string GetUsernameById(int UserId)
        {
            string Name = "Unknown User";

            GameClient Client = GetGame().GetClientManager().GetClientByUserID(UserId);

            if (Client != null && Client.GetHabbo() != null)
            {
                return(Client.GetHabbo().Username);
            }

            UserCache User = HabboEnvironment.GetGame().GetCacheManager().GenerateUser(UserId);

            if (User != null)
            {
                return(User.Username);
            }

            using (IQueryAdapter dbClient = HabboEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `username` FROM `users` WHERE id = @id LIMIT 1");
                dbClient.AddParameter("id", UserId);
                Name = dbClient.getString();
            }

            if (string.IsNullOrEmpty(Name))
            {
                Name = "Unknown User";
            }

            return(Name);
        }