How to Properly shut down your Emulator...

Moon

If life is a Bitch, Fuck it |
Dec 25, 2017
59
20
Okay, so most people don't know how to properly shut down the emulator, and just close it usually via the task manager or other means however this can cause loss of data, emulator to break etc. So I'm going to teach you how to shut down your emulator, it's extremely simple & neccessary, so please before you turn off your VPS,Dedi or Computer go to your emulator and type this in.
Code:
stop
Simple as that, then it should display everything shutting down and close itself, this works on the majority of emulators.

Yes I know this is extremely simple but most people don't know how to actually do this so I hope this teaches a few people
thanks.
-Moon :)
 

ZaneyRetros

i am dead
Jul 27, 2015
211
105
This is useful for people who just right click their Emulator and just click ''Close this window'', when they launch their Emulator they have a ton of errors.

Many Regards,
Zane
 

Cankiee

Member
May 12, 2013
30
10
that-post-gave-me-aids.jpg
 

dogfishcat

New Member
Feb 11, 2018
1
0
Interested, although many people should already know this, and not have to be taught.

What I've done on my emulator is add hotkeys, when holding down CTRL + C you can close the emulator, but holding CTRL + R reboots the emulator, both take 5 seconds, feel free to use this. I would release this in its own thread, but the code isn't a full release as it's not coded in Plus, but a basic C# developer should be able to convert it.

Your while loop in Program, use this...
Code:
var rebootAfterClose = false;

while (true)
{
    var input = Console.ReadKey();

    if (input.Key == ConsoleKey.C && input.Modifiers == ConsoleModifiers.Control)
    {
        break;
    }

    if (input.Key != ConsoleKey.R || input.Modifiers != ConsoleModifiers.Control)
    {
        continue;
    }

    rebootAfterClose = true;

    break;
}

Server?.Stop(rebootAfterClose);

You should probably run Stop() method in a separate task too, not too sure but I think they thread.Sleep for 5 seconds? this way the users don't freeze until shutdown or reboot.
Code:
public void Stop(bool restart)
{
    Task.Factory.StartNew(() =>
    {
        var shutdownMessage = Program.Server.LanguageHandler.TryGetValue("server.shutdown.message");
        var shutdownPacket = new BroadcastMessageAlertComposer(shutdownMessage);

        Program.Server.GameHandler.PlayerHandler.SendPacketToPlayers(shutdownPacket);

        ConsoleUpdater.Stop();

        Console.Clear();
        Console.WriteLine();
        Console.Title = "Stopping...";

        Logger.Warn("Server is " + (restart ? "rebooting" : "shutting down") + "....");

        Thread.Sleep(5000);

        Dispose();

        if (restart)
        {
            Process.Start(Assembly.GetExecutingAssembly().Location);
        }

        Environment.Exit(0);
    }).Wait();
}
 
Last edited:

5050

Member
Feb 25, 2015
34
13
Are you telling me I'm not supposed to force shutdown my VPS every time I want to shut off my Emulator? This is life-changing, thank you.
 
Last edited:

Users who are viewing this thread

Top