[Release]Console Commands with a bit of color [CoEmu V2]

07/19/2009 06:50 hunterman01#1
Alright here it is dident take to long to make

Umm there is one thing you will have to do that is not very hard and that is add a defintion for CSocket This is for the Game Server btw
Ok To start off Add To Nano.cs
Code:
using System.Diagnostics;


Then add
Code:
using System.Windows.Forms;

After That add Preferably at the bottom but it is your choice
Code:
public static void ServerRestart()
        {
            Process nServ = new Process();
            nServ.StartInfo.FileName = Application.StartupPath + @"\CoEmu v2 GameServer";
            nServ.Start();
            Environment.Exit(0);
        }
Then Search for public static void ConsoleCommands() Replace it with this
Code:
public static void ConsoleCommands()
        {
            //Console.WriteLine("Ready for commands.");
            bool unkowncommand = false;
            Console.ForegroundColor = ConsoleColor.Green;
            {
                Console.WriteLine("Type #Help For Console commands!");
            }
            string command = Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.Red;
            {
                if (command == "#Help")
                {
                    Console.WriteLine("************Welcome To The Help Page**********");//Credits To hunterman01
                    Console.WriteLine("Type #Commands For a List of the commands");
                }
            }
            Console.ForegroundColor = ConsoleColor.Blue;
            {
                if (command == "#Commands")
                {
                    Console.WriteLine("Commands Are As Follows");
                    Console.WriteLine("#restart--Which restarts the server");
                    Console.WriteLine("#Server Maitnence--which closes the server in 5 mintues");
                    Console.WriteLine("#message--Which sends a message to the server");
                    Console.WriteLine("#close--Which Closes the server");
                }
            }

            if (command == "#message")
            {
                //CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, CSocket.Client.Name, "ALLUSERS", CoEmu_v2_GameServer.Structs.Struct.ChatType.NewBroadcast), 0);
                //TO-DO ADD A DEFINITION FOR CSocket
            }
            if (command == "#restart")//partial credits to Andrea
            {
                Console.WriteLine("Server Being restarted Now");
                ServerRestart();
            }
            if (command == "#close")
            {
                CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "OWNER", "ALLUSERS", "[GameServer] Shutting down for a restart now!", CoEmu_v2_GameServer.Structs.Struct.ChatType.NewBroadcast), 0);
                Console.Write("Server being shutdown Now!");
                System.Environment.Exit(1);
            }
            if (command == "#Server Maitnence")
            {
                
                Shutdown = new System.Timers.Timer();

                Shutdown.Interval = 180000;
                Shutdown.AutoReset = false;
                Shutdown.Elapsed += delegate { Kill(); };
                Shutdown.Start();
                CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 3 minutes.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
                unkowncommand = true;
            }
            else
            {
                if (unkowncommand == true)
                {
                    //Console.WriteLine("Unknown command.");
                }
                ConsoleCommands();
            }
        }

If There is Any Problem let me know and i will update

And you can pretty much do the same thing if you want for the login server its up to you
07/19/2009 08:41 Arcotemple:)#2
how har dis it to make a CP for a server?
07/19/2009 10:53 JustChillin#3
Quote:
Originally Posted by Arcotemple:) View Post
how har dis it to make a CP for a server?
I don't see how that has anything to do with Lotf
07/19/2009 16:55 hunterman01#4
Quote:
Originally Posted by Arcotemple:) View Post
how har dis it to make a CP for a server?
Its not like its hard but i dont like using control panels

And to Just Chillin or w.e this has nothing to do with lotf 0.0
07/19/2009 17:03 f0am#5
It wont work correctly you made it so its an unknown command = false. it should be true.
07/19/2009 17:12 hunterman01#6
Thanks
07/19/2009 17:30 f0am#7
Actually take out the unknown command thing and make the first

if

then the rest else if and at last else.
07/19/2009 17:52 m7med#8
THERE IS ONE error ( Shutdown.Elapsed += delegate { Kill(); };) but i fix it

generate method
07/19/2009 17:55 AndreaCo#9
lol fail that was me who did that.. sorry filer i was really tired last night 0.o
07/19/2009 20:08 hunterman01#10
Yeah andrea did that its not hard to fix i am just to lazy and ill let whoever wants to use this fix it themselves