41Sqn_Banks
10-07-2012, 12:11 AM
Sometimes it would be useful to react on chat messages in your mission script (e.g. to list the remaining targets). I found the solution at sukhoi.ru, there is a hidden flag in the conf.ini that enables this.
IMPORTANT:
You have to add the following line to your conf.ini or confs.ini file:
[rts]
scriptAppDomain=0
Without that you get a System.Runtime.Serialization.SerializationExceptio n.
This is the code for the mission:
public override void OnBattleStarted()
{
base.OnBattleStarted();
if (GamePlay is GameDef)
{
(GamePlay as GameDef).EventChat += new GameDef.Chat(Mission_EventChat);
}
}
void Mission_EventChat(IPlayer from, string msg)
{
// msg contains the chat message.
// Example: This code causes the server to repeat the message from the player.
if (GamePlay is GameDef)
{
(GamePlay as GameDef).gameInterface.CmdExec("chat " + msg);
}
}
Happy coding :)
IMPORTANT:
You have to add the following line to your conf.ini or confs.ini file:
[rts]
scriptAppDomain=0
Without that you get a System.Runtime.Serialization.SerializationExceptio n.
This is the code for the mission:
public override void OnBattleStarted()
{
base.OnBattleStarted();
if (GamePlay is GameDef)
{
(GamePlay as GameDef).EventChat += new GameDef.Chat(Mission_EventChat);
}
}
void Mission_EventChat(IPlayer from, string msg)
{
// msg contains the chat message.
// Example: This code causes the server to repeat the message from the player.
if (GamePlay is GameDef)
{
(GamePlay as GameDef).gameInterface.CmdExec("chat " + msg);
}
}
Happy coding :)