Save() публичный статический Метод

public static Save ( ) : void
Результат void
Пример #1
0
 public static void Save()
 {
     AutoSave.Save(false);
 }
Пример #2
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);
            }
        }
Пример #3
0
        private static void ProcessCommand(string input)
        {
            input = input.Trim();

            if (_Pages != null)
            {
                HandlePaging(input);
                return;
            }

            if (input.StartsWith("pages", StringComparison.OrdinalIgnoreCase))
            {
                HandlePaging(input.Substring(5).Trim());
                return;
            }

            if (input.StartsWith("bc", StringComparison.OrdinalIgnoreCase))
            {
                string sub = input.Substring(2).Trim();

                BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Admin] {0}", sub));

                Console.WriteLine("[World]: {0}", sub);
                return;
            }

            if (input.StartsWith("sc", StringComparison.OrdinalIgnoreCase))
            {
                string sub = input.Substring(2).Trim();

                BroadcastMessage(AccessLevel.Counselor, 0x32, String.Format("[Admin] {0}", sub));

                Console.WriteLine("[Staff]: {0}", sub);
                return;
            }

            if (input.StartsWith("ban", StringComparison.OrdinalIgnoreCase))
            {
                string sub = input.Substring(3).Trim();

                System.Collections.Generic.List <NetState> states = NetState.Instances;

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

                NetState ns = states.Find(o => o.Account != null && o.Mobile != null && Insensitive.StartsWith(sub, o.Mobile.RawName));

                if (ns != null)
                {
                    Console.WriteLine("[Ban]: {0}: Mobile: '{1}' Account: '{2}'", ns, ns.Mobile.RawName, ns.Account.Username);

                    ns.Dispose();
                }

                return;
            }

            if (input.StartsWith("kick", StringComparison.OrdinalIgnoreCase))
            {
                string sub = input.Substring(4).Trim();

                System.Collections.Generic.List <NetState> states = NetState.Instances;

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

                NetState ns = states.Find(o => o.Account != null && o.Mobile != null && Insensitive.StartsWith(sub, o.Mobile.RawName));

                if (ns != null)
                {
                    Console.WriteLine("[Kick]: {0}: Mobile: '{1}' Account: '{2}'", ns, ns.Mobile.RawName, ns.Account.Username);

                    ns.Dispose();
                }

                return;
            }

            switch (input.Trim())
            {
            case "crash":
            {
                Timer.DelayCall(() => { throw new Exception("Forced Crash"); });
            }
            break;

            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":
            {
                System.Collections.Generic.List <NetState> 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":     // Credit to Zippy for the HearAll script!
            {
                _HearConsole = !_HearConsole;

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

            default:
                DisplayHelp();
                break;
            }
        }
Пример #4
0
        private void Restart_Callback()
        {
            AutoSave.Save();

            Core.Kill(true);
        }
Пример #5
0
 public static void Save()
 {
     AutoSave.Save(true);
 }
Пример #6
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);
            }
        }