View Single Post
  #1  
Old 05-25-2011, 02:12 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default IL-2 Server Master v1.0

IL-2 Server Master is software that allows you to interact with a mission script while it is running. With this software, you can run portions of your script on demand. Possibilities are many. Let your imagination run wild!

Here is an abridged version of the manual included with the software.

Install

1. Extract IL2ServerMasterLibrary.dll to "Steam\steamapps\common\il-2 sturmovik cliffs of dover\".

2. Put the following code in you mission's script.

Code:
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using System.Reflection;
using System.IO;


public class Mission : AMission
{
    MethodInfo mi;
    Type classType;
    object obj;

    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        try
        {
            //Load the new DLL from the specified path and set the current method to popCommand().
            Assembly a = null;
            a = Assembly.LoadFrom(Directory.GetCurrentDirectory() + @"\IL2ServerMasterLibrary.dll");
            classType = a.GetType("IL2ServerMasterLibrary.ServerMaster");
            obj = Activator.CreateInstance(classType, new object[] { "password", 11000 });  //First argument is the password, second is port number.
            mi = classType.GetMethod("popCommand");
        }
        catch (Exception e)
        {
            GamePlay.gpLogServer(new Player[] { GamePlay.gpPlayer() }, "Could not load Server Master. :(", null);
        }
    }
    public override void OnBattleStoped()
    {
        base.OnBattleStoped();

        //Set method to Stop(). Stop the DLL.
        mi = classType.GetMethod("Stop");
        mi.Invoke(obj, null);
    }


    public override void OnTickGame()
    {
        base.OnTickGame();

        //get the command from Server Master
        string[] command = (string[])mi.Invoke(obj, null);

        //if command is not null, there is a command to be executed
        if (command != null)
        {
            // Do the command.
        }
    }  
}
3. Change password and port number in above code to appropriate values. Port can be left default if desired. You may need to open the port in your firewall to access the server throught the internet.

4. Start your server with the new script and fire up the included executable.

5. Send a command to your server. If the server receives the command you will get a message next to the "Send Command" button.

6. Write code to actually do something with the commands. My code returns commands in an array of strings. The string at position zero is the command, the rest are the arguments. It returns null if there are no commands to be executed. There is an example of how to get a command in the above code.


As this is the first release, there may be bugs in it. If you need any help using it or getting it installed, I'd be happy to help. Feature requests are welcome also.

Airwarfare.com Download
Attached Files
File Type: zip IL2ServerMasterv10.zip (249.6 KB, 74 views)

Last edited by TheEnlightenedFlorist; 05-26-2011 at 04:23 AM.
Reply With Quote