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!

Developer Question, WM_MESSAGE's with WorldSave

ClearDark

Wanderer
Developer Question, WM_MESSAGE's with WorldSave

Hey, im developing in Microsoft Visual C++, i wondered if there is a WM_ message i can send the the RunUO window to perform a worldsave...and if it exists, what will the message params and number be?

Thanks..ClearDark
 

FlameGod

Wanderer
Re: Developer Question, WM_MESSAGE's with WorldSave

ClearDark said:
Hey, im developing in Microsoft Visual C++, i wondered if there is a WM_ message i can send the the RunUO window to perform a worldsave...and if it exists, what will the message params and number be?

Thanks..ClearDark

There is some script that let's you save the world throught tipping some commands in the Console window of the RunUO. You can install this script and then just send the commands with the help of WM_CHAR.
 

FlameGod

Wanderer
[code:1]
//by Shurugwi, Console Commands (Ver 1.0)
//edit/add gangpung 2003.02.07 (Ver 1.1)
//add, AccountAdd / AccountDel

using System;
using System.Threading;
using System.Diagnostics;
using System.ComponentModel;
using Server;
using Server.Network;
using Server.Accounting;

class ConsoleCMD {

/// <summary>
/// Console Command interpreter for RunUO
/// </summary>

public static void Initialize()
{
StartConsole(false);
}

public static void StartConsole(bool showprompt)
{
if (showprompt)
{
Console.WriteLine("[RunUO <? for help>]");
}

AutoResetEvent asyncOpIsDone = new AutoResetEvent(false);
ThreadPool.QueueUserWorkItem(new WaitCallback(RunUOConsole), asyncOpIsDone);
return;
}

static void RunUOConsole(Object state)
{
string i = Console.ReadLine();
if (i.Length > 0)
{
switch(i.ToUpper())
{
case "HELP":
case "?":
{
ShowHelp();
break;
}

case "SAVE":
case "S":
{
World.Save();
Console.WriteLine();
break;
}

case "RESTART":
case "RS":
{
Console.WriteLine( "Restarting..." );
World.Save();
Restart(true);
break;
}

case "RNS":
case "RESTART NO SAVE":
{
Console.WriteLine( "Restarting..." );
Restart(true);
break;
}

case "SHUTDOWN":
case "SS":
{
World.Save();
Console.WriteLine( "Shutting down..." );
Restart(false);
break;
}

case "SHUTDOWN NO SAVE":
case "SNS":
{
Console.WriteLine( "Shutting down..." );
Restart(false);
break;
}

/*
* Due to problems with timers not stopping, recompiling is not advised. Use restart instead.
*
case "RECOMPILE":
case "RC":
{
Recompile();
return;
} */

case "STATS":
{
ShowShardStats();
break;
}

case "PSTATS":
case "PS":
{
ShowRUOStats();
break;
}

default:
{
Console.WriteLine("Invalid Command:");
ShowHelp();
break;
}
case "ACCOUNT":
case "ACC":
{
AccountHelp();
break;
}
case "ACCOUNTADD":
case "ACCADD":
{
Console.WriteLine(" Type Account Name");
string acct;
acct = Console.ReadLine();
Console.WriteLine(" Type Password");
string pass;
pass = Console.ReadLine();
Accounts.AddAccount( acct, pass );
Console.WriteLine(" Registe Account [{0}/{1}]. TotalAccount[{2}]", acct.ToString(), pass.ToString(), Accounts.Table.Count );
break;
}
case "ACCOUNTDELETE":
case "ACCDEL":
{
Console.WriteLine(" Delete Account Name. [{0}]", Accounts.Table.Count );
string acct;
acct = Console.ReadLine();
Accounts.Table.Remove( acct );
Console.WriteLine(" OK! Delete Account : [{0}]. TotalAccount : {1}", acct.ToString(), Accounts.Table.Count );
break;
}
}
}
StartConsole(true);
}

static void ShowHelp()
{
Console.WriteLine("\nConsole Command list");
Console.WriteLine("-=Command=-\t\t-=Description=-\t\t\t-=Shortcut=-");
Console.WriteLine(".-------------------------------------------------------------------- - - -");
Console.WriteLine("| Help\t\t\t- Show this help file\t\t- ?");
Console.WriteLine("| Save\t\t\t- Save World\t\t\t- S");
Console.WriteLine("| Restart\t\t- Restart Server(Saving)\t- RS");
Console.WriteLine("| Restart No Save\t- Restart Server(NO Saving)\t- RNS");
Console.WriteLine("| Shutdown\t\t- Shutdown Server(Saving)\t- SS");
Console.WriteLine("| Shutdown No Save\t- Shutdown Server(NO Saving)\t- SNS");
Console.WriteLine("| Stats\t\t\t- Server Stats\t\t\t- N/A");
//Console.WriteLine("| Recompile\t\t- Recompile Scripts\t\t- RC");
Console.WriteLine("| PStats\t\t- RunUO Stats\t\t\t- PS");
Console.WriteLine(".-------------------------------------------------------------------- - - -");
Console.WriteLine("Account\t\t\t\t- Account About\t\t\t\t - ACC");
Console.WriteLine("AccountAdd\t\t\t- Account Register\t\t\t\t- ACCADD");
Console.WriteLine("AccountDelete\t\t- Account Delete\t\t\t\t- ACCDEL");
Console.WriteLine("'------- - - -\n");
Console.WriteLine("** Commands are NOT case sensitive\n");
return;
}

static void Restart(bool restart)
{
try
{
Process[] list = Process.GetProcessesByName("runuo");
if (restart)
{
Process.Start(Core.ExePath );
}
foreach (Process p in list)
p.Kill();

}
catch
{
Console.WriteLine( "Restart Failed" );
}
}

public static void Recompile()
{
Console.WriteLine("Recompiling scripts, please wait.");
if ( !ScriptCompiler.Compile() )
Console.WriteLine( "There were errors recompiling the scripts, the last good version will be used." );
else
Console.WriteLine( "Scripts recompiled successfully." );
}

static void ShowRUOStats()
{
try
{
Process[] list = Process.GetProcessesByName("runuo");
foreach (Process p in list)
{
Console.WriteLine("\n.--------=[ RunUO Usage Information ]=---- - - -");
Console.WriteLine("| Physical Memory:\t" + p.WorkingSet / 1024 + "k");
Console.WriteLine("| Peak Physical Memory:\t" + p.PeakWorkingSet / 1024 + "k");
Console.WriteLine("| Virtual Memory:\t" + p.VirtualMemorySize / 1024 + "k");
Console.WriteLine("| Peak Virtual Memory:\t" + p.PeakVirtualMemorySize / 1024 + "k");
Console.WriteLine("| Total Processor Time:\t" + p.TotalProcessorTime);
Console.WriteLine("| User Processor Time:\t" + p.UserProcessorTime);
Console.WriteLine("'------- - - -\n");
}
}
catch
{
Console.WriteLine( "Could not find 'RunUO' process" );
}
}

static void ShowShardStats()
{
Console.WriteLine("\n.--------=[ Shard Statistics ]=---- - - -");
Console.WriteLine("| Players:\t" + NetState.Instances.Count);
Console.WriteLine("| NPCs:\t\t" + World.Mobiles.Count);
Console.WriteLine("| Items:\t" + World.Items.Count);
Console.WriteLine("'------- - - -\n");
}
static void AccountHelp()
{
Console.WriteLine(" TotalAccount : {0}", Accounts.Table.Count);
Console.WriteLine(" Account Registe : AccAdd, Account Delete : AccDel");
return;
}
}

[/code:1]
 

Ryan

RunUO Founder
Staff member
I've said it once and I will say it again.

DO NOT USE RECOMPILE ON A PRODUCTION SHARD ITS FOR DEVELOPMENT PURPOSES ONLY :)

Kthx!
 
Top