Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   Write to Launcher console process? (http://forum.fulqrumpublishing.com/showthread.php?t=32546)

salmo 06-06-2012 05:07 AM

Write to Launcher console process?
 
I'm trying to write to the MP Launcher console from a sub-mission script. The code below works in the main mission script ie. It will write the connection status in the console window, but it fails where I put the same script in the sub-mission script.cs. I thought I might have to construct a process-writer to write from the sub-mission to the Launcher console, but I can't get this to work. Help appeciated.

code removed by author

I've tried this but often come up with a "System.Array does not contain a definition for StandardInput"
inputWriter = process.StandardInput; // Create the console writer (fails)
inputWriter.WriteLine("... Connected to MP game console failed.");
//process.WriteLine("... Connected to MP game console failed.");

ATAG_Colander 06-06-2012 06:46 PM

I haven't tried it but you might want to try AttachConsole(-1).

salmo 06-07-2012 05:38 AM

Quote:

Originally Posted by ATAG_Colander (Post 432618)
I haven't tried it but you might want to try AttachConsole(-1).

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 ...

moggel 06-15-2012 09:55 AM

Quote:

Originally Posted by salmo (Post 432716)
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.

FG28_Kodiak 06-15-2012 10:01 AM

On Dedicated Server you can use GamePlay.gpPlayer() to write to the Console, on Dedi gpPlayer() is the server itself.
null sends the message to all, with the gpPlayer only the server (Console) gets the message.

salmo 08-04-2012 09:19 AM

Quote:

Originally Posted by FG28_Kodiak (Post 435100)
On Dedicated Server you can use GamePlay.gpPlayer() to write to the Console, on Dedi gpPlayer() is the server itself.
null sends the message to all, with the gpPlayer only the server (Console) gets the message.

This fails Kodiak? Help please :)
GamePlay.gpLogServer(GamePlay.gpPlayer(), "... Connected to MP launcher console OK.", null);

hc_wolf 08-04-2012 01:05 PM

does this help?

Code:

    private void sendChatMessageTo(int army, string msg, object[] parms)
    {
        List<Player> Players = new List<Player>();

        //Singleplayer or Dedi Server
        if (GamePlay.gpPlayer() != null)
        {
            if (GamePlay.gpPlayer().Army() == army || army == -1)
                Players.Add(GamePlay.gpPlayer());
        } // Multiplayer
        if (GamePlay.gpRemotePlayers() != null || GamePlay.gpRemotePlayers().Length > 0)
        {
            foreach (Player p in GamePlay.gpRemotePlayers())
            {
                if (p.Army() == army || army == -1)
                    Players.Add(p);
            }
        }
        if (Players != null && Players.Count > 0)
            GamePlay.gpLogServer(Players.ToArray(), msg, parms);
    }


salmo 08-04-2012 01:28 PM

Sorry to say it doesn't Wolf. I'm trying to write script-log information to the Launcher console from a sub-mission script, not write to the game screen chat window.

podvoxx 08-04-2012 02:53 PM

Quote:

Originally Posted by salmo (Post 451358)
Sorry to say it doesn't Wolf. I'm trying to write script-log information to the Launcher console from a sub-mission script, not write to the game screen chat window.

http://www.sukhoi.ru/forum/showthrea...65#post1875465

Ask about this naryv on Sukhoi.ru, he know how do this.

salmo 08-13-2012 02:14 PM

I've tried using the 'Sending server console commands from script' example below, but the code below throws a "missing reference required error" at the line in the sub-mission script where SendServerCommand function is called :(


All times are GMT. The time now is 10:37 PM.

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