[RELEASE] Console Commands for Lame Console Look

11/18/2008 14:51 taguro#1
Well, to avoid any further useless posts on this subject... here are a ton of console based commands that will control the game from the server console. I will not explain what each does, it should be pretty easy to figure out, and I don't intend to answer stupid questions. If its a good question, I will answer it.

Code:
        public static void DoStuff()
        {
            bool flag = true;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("*^* Console Command Successfully Loaded *^*");
            Console.WriteLine("");
            Console.ResetColor();
            Console.WriteLine("-- Type .help for a list of the available commands --");
            while (flag)
            {
                string str;
                str = Console.ReadLine();
                if (str == ".close")
                {
                    try
                    {
                        foreach (DictionaryEntry DE in World.AllChars)
                        {
                            Character Char = (Character)DE.Value;
                            DataBase.ChangeOnlineStatus(Char.MyClient.Account, 0);
                        }
                        World.SaveAllChars();
                        sw.Flush();
                        sw.Close();
                        DataBase.AllOffline();
                        Environment.Exit(Environment.ExitCode);
                    }
                    catch { }
                }
                if (str == ".restart")
                {
                    World.SendMsgToAll("Server Restart in 10 seconds!", "SYSTEM", 2011);
                    new Thread(new ThreadStart(
                     delegate()
                     {
                         Console.WriteLine("Server Restarting in 10 seconds!");
                         Thread.Sleep(10000);
                         General.ServerRestart();
                     }
                  )).Start();
                }
                if (str == ".clear")
                {
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("*^* Server Source *^*");
                    Console.WriteLine("-=-=-=-=-=-=-=-=-=-=");
                    Console.ResetColor();
                }
                if (str == ".help")
                {
                    Console.WriteLine("\nCurrent Console Commands: \n.clear - Clears Console \n.restart - Restarts Server \n.close - Closes Server (and saves characters) \n.message - Sends in-Game GM Message \n.sm - Automated 5-minute Server Maintenance Command\n.playershow - Shows who is on and how many clients are connected to the server.");
                }
                if (str == ".sm")
                {
                    World.SendMsgToAll("Server Maintanience in 5 minutes! Please log off to avord data lost!", "SYSTEM", 2011);
                    new Thread(new ThreadStart(
                    delegate()
                    {
                        Console.WriteLine("Server Maintenance Command Activated (via Console).");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 4 minutes and 30 Seconds! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("4:30 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 4 minutes! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("4 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 3 minutes and 30 Seconds! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("3:30 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 3 minutes! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("3 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 2 minutes and 30 Seconds! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("2:30 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 2 minutes! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("2 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 1 minute and 30 Seconds! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("1:30 Minutes Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 1 minute! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("1 Minute Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance in 30 Seconds! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Console.WriteLine("0:30 Seconds Left");
                        Thread.Sleep(30000); // 30 second
                        World.SendMsgToAll("Server Maintenance for 30 minutes! Please Log off to prevent data loss!", "SYSTEM", 2011);
                        Thread.Sleep(10000); // 30 second
                        Console.WriteLine("Server is now shutting down...");
                        try
                        {
                            foreach (DictionaryEntry DE in World.AllChars)
                            {
                                Character Char = (Character)DE.Value;
                                DataBase.ChangeOnlineStatus(Char.MyClient.Account, 0);
                            }
                            World.PlayersOffLottery();
                            World.SaveAllChars();
                            sw.Flush();
                            sw.Close();
                            DataBase.AllOffline();
                            Environment.Exit(Environment.ExitCode);
                        }
                        catch { }



                    }
                 )).Start();


                }
                if (str.StartsWith(".message"))
                {
                    string msg;
                    msg = str.Substring(8);
                    World.SendMsgToAll(msg, "SYSTEM", 2011);
                    Console.WriteLine("Sent Message");
                }
                if (str.StartsWith(".playershow"))
                {
                    string BackMsg = "";
                    foreach (DictionaryEntry DE in World.AllChars)
                    {
                        Character Char = (Character)DE.Value;
                        BackMsg += Char.Name + ", ";
                    }
                    if (BackMsg.Length > 1)
                        BackMsg = BackMsg.Remove(BackMsg.Length - 2, 2);
                    Console.WriteLine("Players Online: " + World.AllChars.Count + "\n" + BackMsg);

                }
            }
        }
11/18/2008 14:57 tao4229#2
Just wondering, where'd you get these commands from?
11/18/2008 15:05 Korvacs#3
You should imo modify this to work in a seperate thread, otherwise your going to see increased latency....
11/18/2008 15:15 Exia13#4
LOL, i didnt think you'd release them. Well, i guess they'd come out sooner or later :p

Just testing the commands, but how how do you actually execute them once they're typed (tried pressing enter but i forgot that it closes the console.)
11/18/2008 16:29 Korvacs#5
Quote:
Originally Posted by Exia13 View Post
LOL, i didnt think you'd release them. Well, i guess they'd come out sooner or later :p

Just testing the commands, but how how do you actually execute them once they're typed (tried pressing enter but i forgot that it closes the console.)
Anouther good reason to have it in a sepeare thread, but from the code posted the console wont close when you hit enter, it will just read the line and perform the commands listed
11/18/2008 16:31 tao4229#6
Quote:
Originally Posted by Exia13 View Post
LOL, i didnt think you'd release them. Well, i guess they'd come out sooner or later :p

Just testing the commands, but how how do you actually execute them once they're typed (tried pressing enter but i forgot that it closes the console.)
You have to actually call the method :p

After you load all the crap call the method.
11/18/2008 16:32 Exia13#7
Well ok. But like i said, i wont be using this.
12/23/2008 16:31 flamesco#8
thanks for the commands, i like this console better than my other one =] i hit thanks button
07/23/2009 22:20 Pyro-G#9
Where do I put this code?=D
07/24/2009 03:49 © Haydz#10
Quote:
Originally Posted by Pyro-G View Post
Where do I put this code?=D
AssemblyInfo.cs
07/24/2009 04:45 f0am#11
This is for lotf lol..
12/07/2011 00:51 jervz#12
:( urghhh
12/07/2011 04:02 -Sensei-#13
damn this kid