Beispiel #1
0
        public static void Next(string input)
        {
            if (Core.Crashed)
            {
                return;
            }

            input = input.ToLower();

            if (input.StartsWith("bc"))
            {
                var sub = input.Replace("bc", "");

                BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Admin] {0}", sub));
                Console.WriteLine("Players will see: {0}", sub);
            }
            else if (input.StartsWith("sc"))
            {
                var sub = input.Replace("staff", "");

                BroadcastMessage(AccessLevel.Counselor, 0x32, String.Format("[Admin] {0}", sub));
                Console.WriteLine("Staff will see: {0}", sub);
            }
            else if (input.StartsWith("ban"))
            {
                var sub    = input.Replace("ban", "");
                var states = NetState.Instances;

                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }

                foreach (var t in states)
                {
                    var a = t.Account as Account;

                    if (a == null)
                    {
                        continue;
                    }

                    var m = t.Mobile;

                    if (m == null)
                    {
                        continue;
                    }

                    sub = sub.ToLower();

                    if (m.Name.ToLower() != sub.Trim())
                    {
                        continue;
                    }

                    var m_ns = m.NetState;

                    Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);

                    a.Banned = true;
                    m_ns.Dispose();

                    Console.WriteLine("Banning complete.");
                }
            }
            else if (input.StartsWith("kick"))
            {
                var sub    = input.Replace("kick", "");
                var states = NetState.Instances;

                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }

                foreach (var t in states)
                {
                    var a = t.Account as Account;

                    if (a == null)
                    {
                        continue;
                    }

                    var m = t.Mobile;

                    if (m == null)
                    {
                        continue;
                    }

                    sub = sub.ToLower();

                    if (m.Name.ToLower() != sub.Trim())
                    {
                        continue;
                    }

                    var m_ns = m.NetState;

                    Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);

                    m_ns.Dispose();

                    Console.WriteLine("Kicking complete.");
                }
            }
            else
            {
                switch (input.Trim())
                {
                case "shutdown":
                {
                    AutoSave.Save();
                    Core.Kill(false);
                }
                break;

                case "shutdown nosave":
                {
                    Core.Kill(false);
                }
                break;

                case "restart":
                {
                    AutoSave.Save();
                    Core.Kill(true);
                }
                break;

                case "restart nosave":
                {
                    Core.Kill(true);
                }
                break;

                case "online":
                {
                    var states = NetState.Instances;

                    if (states.Count == 0)
                    {
                        Console.WriteLine("There are no users online at this time.");
                    }

                    foreach (var t in states)
                    {
                        var a = t.Account as Account;

                        if (a == null)
                        {
                            continue;
                        }

                        var m = t.Mobile;

                        if (m != null)
                        {
                            Console.WriteLine("- Account: {0}, Name: {1}, IP: {2}", a.Username, m.Name, t);
                        }
                    }
                }
                break;

                case "save":
                    AutoSave.Save(false);
                    break;

                case "hear":                         //credit to Zippy for the HearAll script!
                {
                    _HearConsole = !_HearConsole;

                    Console.WriteLine(
                        _HearConsole ? "Now sending all speech to the console." : "No longer sending speech to the console.");
                }
                break;

                case "pages":
                {
                    Paging = true;

                    var       list = PageQueue.List;
                    PageEntry e;

                    for (var i = 0; i < list.Count;)
                    {
                        e = (PageEntry)list[i];

                        if (e.Sender.Deleted || e.Sender.NetState == null)
                        {
                            e.AddResponse(e.Sender, "[Logout]");
                            PageQueue.Remove(e);
                        }
                        else
                        {
                            ++i;
                        }
                    }

                    _List = (PageEntry[])list.ToArray(typeof(PageEntry));

                    if (_List.Length > 0)
                    {
                        for (var i = 0; i < _List.Length; ++i)
                        {
                            e = _List[i];

                            var type = PageQueue.GetPageTypeName(e.Type);

                            Console.WriteLine("--------------Page Number: " + i + " --------------------");
                            Console.WriteLine("Player   :" + e.Sender.Name);
                            Console.WriteLine("Catagory :" + type);
                            Console.WriteLine("Message  :" + e.Message);
                        }

                        Console.WriteLine("Type the number of the page to respond to.");

                        ThreadPool.QueueUserWorkItem(PageResp, new object[] { 1, 2 });
                    }
                    else
                    {
                        Console.WriteLine("No pages to display.");

                        Paging = false;
                    }
                }
                break;

                //case "help":
                //case "list":
                default:
                {
                    Console.WriteLine(" ");
                    Console.WriteLine("Commands:");
                    Console.WriteLine("save            - Performs a save.");
                    Console.WriteLine("shutdown        - Performs a save, then shuts down the server");
                    Console.WriteLine("shutdown nosave - Shuts down the server without saving");
                    Console.WriteLine("restart         - Performs a save, then restarts the server");
                    Console.WriteLine("restart nosave  - Restarts the server without saving");
                    Console.WriteLine("online          - Shows a list of every person online:");
                    Console.WriteLine("                      Account, Char Name, IP");
                    Console.WriteLine("bc <message>    - Sends a message to all players");
                    Console.WriteLine("sc <message>    - Sends a message to all staff");
                    Console.WriteLine("hear            - Forwards all local speech to this console:");
                    Console.WriteLine("                      Char Name (Region name): Speech");
                    Console.WriteLine("pages           - Manage help pages");
                    Console.WriteLine("ban <name>      - Kicks and bans the user");
                    Console.WriteLine("kick <name>     - Kicks the user");
                    Console.WriteLine("list or help    - Shows this list");
                    Console.WriteLine(" ");
                }
                break;
                }
            }

            if (!Paging)
            {
                ThreadPool.QueueUserWorkItem(ConsoleListen);
            }
        }
        public static void Next(string nput)
        {
            string input = nput.ToLower();

            if (input.StartsWith("bc"))
            {
                string imput = input.Replace("bc", "");
                BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Admin] {0}", imput));
                Console.WriteLine("Players will see: {0}", imput);
            }
            else if (input.StartsWith("sc"))
            {
                string imput = input.Replace("staff", "");
                BroadcastMessage(AccessLevel.Counselor, 0x32, String.Format("[Admin] {0}", imput));
                Console.WriteLine("Staff will see: {0}", imput);
            }
            else if (input.StartsWith("ban"))
            {
                string          imput  = input.Replace("ban", "");
                List <NetState> states = NetState.Instances;
                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }
                for (int i = 0; i < states.Count; ++i)
                {
                    Account a = states[i].Account as Account;
                    if (a == null)
                    {
                        continue;
                    }
                    Mobile m = states[i].Mobile;
                    if (m == null)
                    {
                        continue;
                    }
                    string innput = imput.ToLower();
                    if (m.Name.ToLower() == innput.Trim())
                    {
                        NetState m_ns = m.NetState;
                        Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);
                        a.Banned = true;
                        m_ns.Dispose();
                        Console.WriteLine("Banning complete.");
                    }
                }
            }
            else if (input.StartsWith("kick"))
            {
                string          imput  = input.Replace("kick", "");
                List <NetState> states = NetState.Instances;
                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }
                for (int i = 0; i < states.Count; ++i)
                {
                    Account a = states[i].Account as Account;
                    if (a == null)
                    {
                        continue;
                    }
                    Mobile m = states[i].Mobile;
                    if (m == null)
                    {
                        continue;
                    }
                    string innput = imput.ToLower();
                    if (m.Name.ToLower() == innput.Trim())
                    {
                        NetState m_ns = m.NetState;
                        Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);
                        m_ns.Dispose();
                        Console.WriteLine("Kicking complete.");
                    }
                }
            }
            else
            {
                switch (input.Trim())
                {
                case "shutdown":
                {
                    Misc.AutoSave.Save();
                    Core.Process.Kill();
                    break;
                }

                case "shutdown nosave":
                    Core.Process.Kill();
                    break;

                case "restart":
                {
                    BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Server] We are restarting..."));
                    Misc.AutoSave.Save();
                    Process.Start(Core.ExePath, Core.Arguments);
                    Core.Process.Kill();
                    break;
                }

                case "restart nosave":
                    Process.Start(Core.ExePath, Core.Arguments);
                    Core.Process.Kill();
                    break;

                case "online":
                {
                    List <NetState> states = NetState.Instances;
                    if (states.Count == 0)
                    {
                        Console.WriteLine("There are no users online at this time.");
                    }
                    for (int i = 0; i < states.Count; ++i)
                    {
                        Account a = states[i].Account as Account;
                        if (a == null)
                        {
                            continue;
                        }
                        Mobile m = states[i].Mobile;
                        if (m != null)
                        {
                            Console.WriteLine("- Account: {0}, Name: {1}, IP: {2}", a.Username, m.Name, states[i]);
                        }
                    }
                    break;
                }

                case "save":
                    Misc.AutoSave.Save();
                    break;

                case "hear":    //credit to Zippy for the HearAll script!
                {
                    Hearconsole = !Hearconsole;
                    if (Hearconsole)
                    {
                        Console.WriteLine("Now sending all speech to the console.");
                    }
                    else
                    {
                        Console.WriteLine("No longer sending speech to the console.");
                    }
                    break;
                }

                case "pages":
                {
                    paging = true;
                    ArrayList list = PageQueue.List;
                    PageEntry e;
                    for (int i = 0; i < list.Count;)
                    {
                        e = (PageEntry)list[i];
                        if (e.Sender.Deleted || e.Sender.NetState == null)
                        {
                            e.AddResponse(e.Sender, "[Logout]");
                            PageQueue.Remove(e);
                        }
                        else
                        {
                            ++i;
                        }
                    }
                    m_List = (PageEntry[])list.ToArray(typeof(PageEntry));
                    if (m_List.Length > 0)
                    {
                        for (int i = 0; i < m_List.Length; ++i)
                        {
                            e = m_List[i];
                            string type = PageQueue.GetPageTypeName(e.Type);
                            Console.WriteLine("--------------Page Number: " + i + " --------------------");
                            Console.WriteLine("Player   :" + e.Sender.Name);
                            Console.WriteLine("Catagory :" + type);
                            Console.WriteLine("Message  :" + e.Message);
                        }
                        Console.WriteLine("Type the number of the page to respond to.");
                        object[] oj = new object[] { 1, 2 };
                        ThreadPool.QueueUserWorkItem(new WaitCallback(PageResp), oj);
                    }
                    else
                    {
                        Console.WriteLine("No pages to display.");
                        paging = false;
                    }
                    break;
                }

                case "help":
                case "list":
                default:
                {
                    Console.WriteLine(" ");
                    Console.WriteLine("Commands:");
                    Console.WriteLine("save            - Performs a forced save.");
                    Console.WriteLine("shutdown        - Performs a forced save then shuts down the server.");
                    Console.WriteLine("shutdown nosave - Shuts down the server without saving.");
                    Console.WriteLine("restart         - Sends a message to players informing them that the server is");
                    Console.WriteLine("                      restarting, performs a forced save, then shuts down and");
                    Console.WriteLine("                      restarts the server.");
                    Console.WriteLine("restart nosave  - Restarts the server without saving.");
                    Console.WriteLine("online          - Shows a list of every person online:");
                    Console.WriteLine("                      Account, Char Name, IP.");
                    Console.WriteLine("bc <message>    - Type this command and your message after it. It will then be");
                    Console.WriteLine("                      sent to all players.");
                    Console.WriteLine("sc <message>    - Type this command and your message after it.It will then be ");
                    Console.WriteLine("                      sent to all staff.");
                    Console.WriteLine("hear            - Copies all local speech to this console:");
                    Console.WriteLine("                      Char Name (Region name): Speech.");
                    Console.WriteLine("pages           - Shows all the pages in the page queue,you type the page");
                    Console.WriteLine("                      number ,then you type your response to the player.");
                    Console.WriteLine("ban <playername>- Kicks and bans the users account.");
                    Console.WriteLine("kick <playername>- Kicks the user.");
                    Console.WriteLine("list or help    - Shows this list.");
                    Console.WriteLine(" ");
                    break;
                }
                }
            }
            if (!paging)
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(ConsoleListen));
            }
        }
Beispiel #3
0
        public static void Next(string input)
        {
            input = input.ToLower();

            if (input.StartsWith("bc"))
            {
                string sub = input.Replace("bc", "");

                BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Admin] {0}", sub));
                Console.WriteLine("Players will see: {0}", sub);
            }
            else if (input.StartsWith("sc"))
            {
                string sub = input.Replace("staff", "");

                BroadcastMessage(AccessLevel.Counselor, 0x32, String.Format("[Admin] {0}", sub));
                Console.WriteLine("Staff will see: {0}", sub);
            }
            else if (input.StartsWith("ban"))
            {
                string sub    = input.Replace("ban", "");
                var    states = NetState.Instances;

                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }

                foreach (NetState t in states)
                {
                    Account a = t.Account as Account;

                    if (a == null)
                    {
                        continue;
                    }

                    Mobile m = t.Mobile;

                    if (m == null)
                    {
                        continue;
                    }

                    sub = sub.ToLower();

                    if (m.Name.ToLower() != sub.Trim())
                    {
                        continue;
                    }

                    NetState m_ns = m.NetState;

                    Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);

                    a.Banned = true;
                    m_ns.Dispose();

                    Console.WriteLine("Banning complete.");
                }
            }
            else if (input.StartsWith("kick"))
            {
                string sub    = input.Replace("kick", "");
                var    states = NetState.Instances;

                if (states.Count == 0)
                {
                    Console.WriteLine("There are no players online.");
                }

                foreach (NetState t in states)
                {
                    Account a = t.Account as Account;

                    if (a == null)
                    {
                        continue;
                    }

                    Mobile m = t.Mobile;

                    if (m == null)
                    {
                        continue;
                    }

                    sub = sub.ToLower();

                    if (m.Name.ToLower() != sub.Trim())
                    {
                        continue;
                    }

                    NetState m_ns = m.NetState;

                    Console.WriteLine("Mobile name: '{0}' Account name: '{1}'", m.Name, a.Username);

                    m_ns.Dispose();

                    Console.WriteLine("Kicking complete.");
                }
            }
            else
            {
                switch (input.Trim())
                {
                case "shutdown":
                {
                    AutoSave.Save();
                    Core.Process.Kill();
                }
                break;

                case "shutdown nosave":
                    Core.Process.Kill();
                    break;

                case "restart":
                {
                    BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Server] We are restarting..."));
                    AutoSave.Save();
                    // this really should call Core.Kill rather than Core.Process.Kill
                    //  to avoid duplicating logic --sith
                    Core.Kill(true);
                }
                break;

                case "restart nosave":
                {
                    Core.Kill(true);
                }
                break;

                case "online":
                {
                    var states = NetState.Instances;

                    if (states.Count == 0)
                    {
                        Console.WriteLine("There are no users online at this time.");
                    }

                    foreach (NetState t in states)
                    {
                        Account a = t.Account as Account;

                        if (a == null)
                        {
                            continue;
                        }

                        Mobile m = t.Mobile;

                        if (m != null)
                        {
                            Console.WriteLine("- Account: {0}, Name: {1}, IP: {2}", a.Username, m.Name, t);
                        }
                    }
                }
                break;

                case "save":
                    AutoSave.Save();
                    break;

                case "hear":
                {
                    _HearConsole = !_HearConsole;

                    Console.WriteLine(
                        _HearConsole
                                ? "Now sending all speech to the console."
                                : "No longer sending speech to the console.");
                }
                break;

                case "pages":
                {
                    Paging = true;

                    ArrayList list = PageQueue.List;
                    PageEntry e;

                    for (int i = 0; i < list.Count;)
                    {
                        e = (PageEntry)list[i];

                        if (e.Sender.Deleted || e.Sender.NetState == null)
                        {
                            e.AddResponse(e.Sender, "[Logout]");
                            PageQueue.Remove(e);
                        }
                        else
                        {
                            ++i;
                        }
                    }

                    _List = (PageEntry[])list.ToArray(typeof(PageEntry));

                    if (_List.Length > 0)
                    {
                        for (int i = 0; i < _List.Length; ++i)
                        {
                            e = _List[i];

                            string type = PageQueue.GetPageTypeName(e.Type);

                            Console.WriteLine("--------------Page Number: " + i + " --------------------");
                            Console.WriteLine("Player   :" + e.Sender.Name);
                            Console.WriteLine("Category :" + type);
                            Console.WriteLine("Message  :" + e.Message);
                        }

                        Console.WriteLine("Type the number of the page to respond to.");

                        ThreadPool.QueueUserWorkItem(PageResp, new object[] { 1, 2 });
                    }
                    else
                    {
                        Console.WriteLine("No pages to display.");

                        Paging = false;
                    }
                }
                break;

                //case "help":
                //case "list":
                default:
                {
                    Console.WriteLine(" ");
                    Console.WriteLine("Commands:");
                    Console.WriteLine("save            - Performs a forced save.");
                    Console.WriteLine("shutdown        - Performs a forced save then shuts down the server.");
                    Console.WriteLine("shutdown nosave - Shuts down the server without saving.");
                    Console.WriteLine(
                        "restart         - Sends a message to players informing them that the server is");
                    Console.WriteLine(
                        "                      restarting, performs a forced save, then shuts down and");
                    Console.WriteLine("                      restarts the server.");
                    Console.WriteLine("restart nosave  - Restarts the server without saving.");
                    Console.WriteLine("online          - Shows a list of every person online:");
                    Console.WriteLine("                      Account, Char Name, IP.");
                    Console.WriteLine(
                        "bc <message>    - Type this command and your message after it. It will then be");
                    Console.WriteLine("                      sent to all players.");
                    Console.WriteLine(
                        "sc <message>    - Type this command and your message after it.It will then be ");
                    Console.WriteLine("                      sent to all staff.");
                    Console.WriteLine("hear            - Copies all local speech to this console:");
                    Console.WriteLine("                      Char Name (Region name): Speech.");
                    Console.WriteLine("pages           - Shows all the pages in the page queue,you type the page");
                    Console.WriteLine("                      number ,then you type your response to the player.");
                    Console.WriteLine("ban <playername>- Kicks and bans the users account.");
                    Console.WriteLine("kick <playername>- Kicks the user.");
                    Console.WriteLine("list or help    - Shows this list.");
                    Console.WriteLine(" ");
                }
                break;
                }
            }

            if (!Paging)
            {
                ThreadPool.QueueUserWorkItem(ConsoleListen);
            }
        }