View Full Version : Write to Launcher console process?
salmo
06-06-2012, 05:07 AM
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
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
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 ...
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.GetProces sesByName("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 :(
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
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?
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
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/showthread.php?t=68629&page=13&p=1875465#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 :(
podvoxx
09-25-2012, 06:30 AM
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 :(
public void SendServerCommand(string command)
#region send a command to the game server console
{
GameServerDef gameServerDef = base.GamePlay as GameServerDef;
if (gameServerDef != null)
{
gameServerDef.consoleInput(command);
}
}
#endregion
http://www.sukhoi.ru/forum/showthread.php?t=68629&p=1880966&viewfull=1#post1880966
I'm very sorry, I lost this topic. If necessary, use this:
using maddox.game;
salmo
09-25-2012, 07:25 AM
http://www.sukhoi.ru/forum/showthread.php?t=68629&p=1880966&viewfull=1#post1880966
I'm very sorry, I lost this topic. If necessary, use this:
using maddox.game;
Thankyou podvoxx. This does not provide a solution however. It's been dificult to get the mesage to the game developers that there are certain C# processes that just don't work when launched from a sub-mission script.
It looks like any server console output or in-game text output fails when you try to perform these from a sub-missions script. These are the C# actions that fail: gpHUDLogCenter, gpLogServer, Console.Write, Console.WriteLine, sayToGroup
Please see details HERE (http://forum.1cpublishing.eu/showthread.php?t=33935&highlight=problem+sub-missions)
vBulletin® v3.8.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.