RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[2.0 & 1.0] Console Commands

[2.0 & 1.0] Console Commands v1.2

Problem with version 1.2? PM me. Problem with 2.x? Post in that thread.

VERSION 2 IS OUT! : http://runuo.com/forums/showthread.php?t=71396


CC Current version: 1.2
Information
With this script, you may input(type) commands into the console(Server.exe) without having to log on.

Supported Commands:
  • Shutdown - Saves and shutsdown the server.
  • Shutdown nosave - Closes the server without saving.
  • Restart - Broadcasts to everyone the server is restarting, saves, and restarts the server.
  • [New] Restart nosave - Restarts the server without saving.
  • Broadcast - Type this command, then it will ask what you would like to broadcast to everyone. It will then rely what it broadcasted, on the console: Player : <what you said here>
  • Staff - Type this command, then it will ask you what you would like to broadcast to your staff. It will then rely what it broadcasted, on the console: Staff : <what you said here>
  • Online - Shows a list of every person online: Account, Char Name, IP.
  • Save - Saves the world.
  • Consolehear - Routes all speech to the console: Char Name (Region name): Speech
  • Listor Help - Shows a list of available commands.

From v1.1 to v1.2:
Various "Performance Enhancement" fixes. New command, restart nosave, added.

Helpers:
Phantom, noobie, Ravatar, Zippy(for the hearall script),DontDropTheSOAD, Lord Neo, Pyro-Tech, HomeDaddy.

Screen Shots:
http://www.imagedonkey.com/show.php?img=11138_CCInAction.bmp.html

Note: Version 1.2A only works for RunUO 2.0
Note: Version 1.2B only works for RunUO 1.0

Suggestions, Comments, Criticism all welcome!
Know a command you want implemented? Suggest it!
 

Attachments

  • CC1.2A.cs
    9.6 KB · Views: 235
  • CC1.2B.cs
    9.5 KB · Views: 149

Lord Neo

Sorceror
Crash Report - Debug

Heres the crash report it produced
Code:
Server Crash Report
===================

RunUO Version 2.0, Build 2357.32527
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 6/21/2006 3:33:46 PM
Mobiles: 5164
Items: 74323
Clients:
- Count: 1


Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Misc.ServerConsole.OnSpeech(SpeechEventArgs args) in c:\Program Files\RunUO\RunUO-2.0-RC1\Scripts\1Custom\CCv1[1].0A.cs:line 35
   at Server.SpeechEventHandler.Invoke(SpeechEventArgs e)
   at Server.EventSink.InvokeSpeech(SpeechEventArgs e)
   at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
   at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue) in c:\Program Files\RunUO\RunUO-2.0-RC1\Scripts\Mobiles\PlayerMobile.cs:line 2224
   at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
 

Pyro-Tech

Knight
Here is another crash report....happened when trying to speak in-game:

it is a debug one....dunno if it is same as lord neo's or not so....

Code:
Server Crash Report
===================

RunUO Version 2.0, Build 2357.32527
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 6/21/2006 5:49:24 PM
Mobiles: 2425
Items: 100042
Clients:
- Count: 1


Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Misc.ServerConsole.OnSpeech(SpeechEventArgs args) in d:\RunUO Server 2.0\Scripts\Custom\New Scripts\Systems\CCv1.0A.cs:line 35
   at Server.SpeechEventHandler.Invoke(SpeechEventArgs e)
   at Server.EventSink.InvokeSpeech(SpeechEventArgs e)
   at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
   at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue) in d:\RunUO Server 2.0\Scripts\Mobiles\PlayerMobile.cs:line 2162
   at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
 
Well, a total of 45 downloads, and only david has something to say about it? Anyone care to share some constructive criticism, or at least a few words on it? :)
 

Evil Jason

Sorceror
As soon as i use it.. i'll give some.. hehe...


wait that sounded bad... well not bad i guess... but.. well. anyway .. I'll let you know.. lol




~Evil Jason
 
this script is awesome. i use it on my 2.0 development shard and it is a life saver. saves the time of having to load of uog then login and then save/shutdown whatever. it has saved me countless minutes.

thanks!
 

HomeDaddy

Wanderer
I love it, saves heaps of time. Don't need to log in to do a save etc.

Great job on this, it is something that was really lacking, in fact when I first set up the server i automatically tried to type save in the console window and was surprised it hadn't been thought of.

Oh, BTW, in the List command you didnt list all the commands, you missed consolehear, so I added that, then got carried away and expanded it to include descriptions of each command, as well as including the clasic 'help' just incase. I also re-arranged the list to, what for me, is a more logical order.
I also changed it so that when you do the restart command, the message it sends is from [Server] not [Staff], so players know it is an automated thing, not just staff telling them, but that's just me.

Here is mine if you would like to see it.

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server;
using System.Threading;
using Server.Commands;
using System.Diagnostics;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Accounting;

namespace Server.Misc
{
    class ServerConsole
    {
        private static bool Hearconsole;
        private static ArrayList m_ConsoleHear = new ArrayList();
        public static void Initialize()
        {
            EventSink.ServerStarted += new ServerStartedEventHandler(EventSink_ServerStarted);
            EventSink.Speech += new SpeechEventHandler(OnSpeech);
        }

        public static void EventSink_ServerStarted()
        {
            new Thread(new ThreadStart(ConsoleListen)).Start();
            Console.WriteLine("CC initialized...");
        }

        private static void OnSpeech(SpeechEventArgs args)
        {
            if (args.Mobile != null)
            {
                try
                {
                    string msg;
                    if (args.Mobile.Region.Name.Length > 0)
                        msg = String.Format("{0} ({1}): {2}", args.Mobile.Name, args.Mobile.Region.Name, args.Speech);
                    else
                        msg = String.Format("{0}: {1}", args.Mobile.Name, args.Speech);
                    if (Hearconsole)
                        Console.WriteLine(msg);
                }
                catch { }
            }
        }
        public static void ConsoleListen()
        {
            string input = Console.ReadLine();
            Next(input);
        }
        public static void PBroadCast()
        {
            string input = Console.ReadLine();
            BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Admin] {0}", input));
            Console.WriteLine("Player: {0}", input);
        }
        public static void SBroadCast()
        {
            string input = Console.ReadLine();
            BroadcastMessage(AccessLevel.Counselor, 0x35, String.Format("[Admin] {0}", input));
            Console.WriteLine("Staff: {0}", input);
        }
        public static void BroadcastMessage(AccessLevel ac, int hue, string message)
        {
            foreach (NetState state in NetState.Instances)
            {
                Mobile m = state.Mobile;

                if (m != null && m.AccessLevel >= ac)
                    m.SendMessage(hue, message);
            }
        }
        public static void Next(string input)
        {
            string line = input.ToLower();
            switch (line)
            {
                case "shutdown":
                    {
                        World.Save();
                        Core.Process.Kill();
                        break;
                    }
                case "shutdown nosave":
                    {
                        Core.Process.Kill();
                        break;
                    }
                case "restart":
                    {
                        BroadcastMessage(AccessLevel.Player, 0x35, String.Format("[Server] The Server is restarting ..."));
                        World.Save();
                        Process.Start(Core.ExePath);
                        Core.Process.Kill();
                        break;
                    }
                case "broadcast":
                    {
                        Console.WriteLine("What would you like to say to everyone?");
                        new Thread(new ThreadStart(PBroadCast)).Start();
                        break;
                    }
                case "online":
                    {
                        ArrayList list = new ArrayList();
                        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 "list":
                    {
			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("online -          Shows a list of every person online:");
			Console.WriteLine("                      Account, Char Name, IP.");
			Console.WriteLine("broadcast -       Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send. The message will then be relayed to all players.");
			Console.WriteLine("Staff -           Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send.  The message will then be relayed to all staff.");
			Console.WriteLine("consolehear -     Copies all local speech to this console:");
			Console.WriteLine("                      Char Name (Region name): Speech.");
			Console.WriteLine("list or help -    Shows this list.");
			Console.WriteLine(" ");
                        break;
                    }
                case "help":
                    {
			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("online -          Shows a list of every person online:");
			Console.WriteLine("                      Account, Char Name, IP.");
			Console.WriteLine("broadcast -       Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send. The message will then be relayed to all players.");
			Console.WriteLine("Staff -           Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send.  The message will then be relayed to all staff.");
			Console.WriteLine("consolehear -     Copies all local speech to this console:");
			Console.WriteLine("                      Char Name (Region name): Speech.");
			Console.WriteLine("list or help -    Shows this list.");
			Console.WriteLine(" ");
                        break;
                    }
                case "save":
                    {
                        World.Save();
                        break;
                    }
                case "staff":
                    {
                        Console.WriteLine("What would you like to say to your staff?");
                        new Thread(new ThreadStart(SBroadCast)).Start();
                        break;
                    }
                case "consolehear"://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;
                    }
                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("online -          Shows a list of every person online:");
			Console.WriteLine("                      Account, Char Name, IP.");
			Console.WriteLine("broadcast -       Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send. The message will then be relayed to all players.");
			Console.WriteLine("Staff -           Type this command, then you will be prompted for a message");
			Console.WriteLine("                      to send.  The message will then be relayed to all staff.");
			Console.WriteLine("consolehear -     Copies all local speech to this console:");
			Console.WriteLine("                      Char Name (Region name): Speech.");
			Console.WriteLine("list or help -    Shows this list.");
			Console.WriteLine(" ");
                        break;
                    }
            }
            new Thread(new ThreadStart(ConsoleListen)).Start();
        }
    }
}

One addition I would like to see is an expansion on the consolehear command so that it includes all public messages etc sent using Knives chat. I think it is the most widely used 'chat' system and I personally haven't seen a shard without it, and having the [c public messages shown as well as local speech would be a great addition, but I wouldn't know where to start.

And everyone, please don't PM saying your shard doesn't use Knives chat, im sure there are a few out there that don't.

Keep up the great work.

HDy
 

HomeDaddy

Wanderer
Nice addition with the Restart nosave, and thanks for the recognition for the verbose list.
I look forward to seeing V1.3 (including the consolehear function echoing knives chat [c messages.... lol)

Keep it up.
HDy
 
Top