Quote:
Also, it turns out there's a much easier way to reference the dll than using reflection.
Code:
//$reference IL2ServerMasterLibrary.dll
using IL2ServerMasterLibrary;Then...
Code:
ServerMaster master = new ServerMaster("pass", 27340);
string[] command = master.popCommand();
|
If using the above syntax in my mission script do I still need the OnBattleStarted/OnBattleStoped methods to declare everything ?
I would think no by your example, but I get the following error in my server log when the above code is used instead of the "Reflections" stuff.
Code:
=================================================
System.Exception: c:\Users\willie\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\main.cs(24,24): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Mission.master'
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.7xH8TZeymA7(String , Boolean , Boolean )
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.o9e0xJrppZOs9Hdpx1qr(Object , Boolean , Boolean )
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.gKP8TsfiPQn(String )
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.x9MliMrTRjjBgALGw0Ov(Object )
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.yJF8aliJrV2(String , Int32 )
=================================================
=================================================
System.Exception: c:\Users\willie\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\main.cs(24,24): error CS0236: A field initializer cannot reference the non-static field, method, or property 'Mission.master'
at elUgjJyQSTyUw5ACkC5.DycAUsynQYrfCiQcD9l.yJF8aliJrV2(String , Int32 )
at LxsOQ2lMvdvAq5WtJux.8x1kchl77DHyoNyKcFY.3utIWKxLiN(vASj0IJYAK5O3O5NAlk )
=================================================
Here is the 1st part of my mission script:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
//$reference IL2ServerMasterLibrary.dll
using IL2ServerMasterLibrary;
public class Mission : AMission
{
// MethodInfo mi;
// Type classType;
// object obj;
int LastMissionLoaded = 0;
double initTime;
ServerMaster master = new ServerMaster("xyz", 27340);
string[] command = master.popCommand();
// 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("missions/IL2ServerMasterLibrary.dll");
// classType = a.GetType("IL2ServerMasterLibrary.ServerMaster");
// obj = Activator.CreateInstance(classType, new object[] { "dover", 11000 });
// //First argument is the password, second is port number.
// mi = classType.GetMethod("popCommand");
// GamePlay.gpLogServer(new Player[] { GamePlay.gpPlayer() }, " - Server Master Loaded", null);
//
// }
// catch (Exception e)
// {
// GamePlay.gpLogServer(new Player[] { GamePlay.gpPlayer() }, "Could not load Server Master. :(" + e.Message + ")", null);
// }
// }
// public override void OnBattleStoped()
// {
// base.OnBattleStoped();
//
// //Set method to Stop(). Stop the DLL.
// mi = classType.GetMethod("Stop");
// mi.Invoke(obj, null);
// }
Any Ideas ?
WildWillie