Quote:
Originally Posted by salmo
Looks like you need a reference to the System.Runtime.InteropServices & the kernel32.dll file which contains the AttachConsole routine. This code-set has no compiler errors but doesn't write to the parent console either ...
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using maddox.GP;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
public class Mission : AMission
{
[DllImport("kernel32.dll", SetLastError = true)] // use the kernel32.dll file routines
static extern bool AttachConsole(uint dwProcessId); // use attachconsole from the kernel32.dll file
const uint ATTACH_PARENT_PROCESS = 0x0ffffffff; // default value if not specifing a process ID
public override void OnBattleStarted()
#region start variables/timers/listeners
{
base.OnBattleStarted();
MissionNumberListener = -1; //listen to events from all missions.
ConnectToLauncherConsole();
}
#endregion
public void ConnectToLauncherConsole()
{
AttachConsole(System.Diagnostics.Process.GetProcessesByName("Launcher")[0].Id); // no error but no cannection either
Console.WriteLine("... Connected to MP launcher console OK.");
AttachConsole(ATTACH_PARENT_PROCESS); // no error but no cannection either
Console.WriteLine("... Connected to MP launcher console OK.");
}
tried setting up a custom console for the sub-mission processes, and again, no compile errors but no console or output
Code:
public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionNumberListener = -1; //listen to events from all missions.
AllocConsole();
Console.Title = "MyTitle";
Console.CursorVisible = true;
Console.OpenStandardInput(256);
Console.OpenStandardOutput(256);
Console.WriteLine("Hello, World!");
// The official music of Dot Net Perls.
for (int i = 37; i <= 32767; i += 200)
{
Console.Beep(i, 100);
}
}
|
Not sure why you want to do this in the first place but if all you need is to get text to show in the MP console window you just need to log it the old fashioned way (call GamePlay.gpLogServer()). Example: gpLogServer(null, "Hello World!"); will print "Hello World" in the MP console window.