Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 06-15-2012, 09:55 AM
moggel moggel is offline
Approved Member
 
Join Date: Mar 2011
Posts: 70
Default

Quote:
Originally Posted by salmo View Post
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.
__________________
Core i7 3930K @ 4.8GHz; 16Gb DDR3 (Vengeance); nVidia GTX580; OS disk: 150Gb 10000rpm; SIM disk: 300Gb 10000rpm; Windows 7 x64 Ultimate
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:05 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.