![]() |
|
|
|
#1
|
|||
|
|||
|
For example i use this in my dll:
Code:
using System.Collections.Generic;
using System.Globalization;
using maddox.game;
using maddox.game.world;
namespace COD
{
public static class Message
{
static readonly IGamePlay GamePlay = Strategy.THIS.GamePlay;
public static void ToChatbar(string msg, params object[] args)
{
GamePlay.gpLogServer(null, msg, args);
}
public static void ToChatbar(Player player, string msg, params object[] args)
{
if (player != null)
GamePlay.gpLogServer(new[] { player }, msg, args);
}
public static void ToChatbar(int army, string msg, params object[] args)
{
var consignees = new List<Player>();
if (GamePlay.gpPlayer() != null)
consignees.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
consignees.AddRange(GamePlay.gpRemotePlayers());
if (army == -1)
GamePlay.gpLogServer(null, msg, args);
else if (consignees.Exists(item => item.Army() == army))
GamePlay.gpLogServer(consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
}
public static void ToScreen(string msg, params object[] args)
{
GamePlay.gpHUDLogCenter(null, msg, args);
}
public static void ToScreen(Player player, string msg, params object[] args)
{
if (player != null)
GamePlay.gpHUDLogCenter(new[] { player }, msg, args);
}
public static void ToScreen(int army, string msg, params object[] args)
{
var consignees = new List<Player>();
if (GamePlay.gpPlayer() != null)
consignees.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
consignees.AddRange(GamePlay.gpRemotePlayers());
if (army == -1)
GamePlay.gpHUDLogCenter(null, msg, args);
else if (consignees.Exists(item => item.Army() == army))
GamePlay.gpHUDLogCenter(consignees.FindAll(item => item.Army() == army).ToArray(), msg, args);
}
public static void ToScreenCountDown(string message, string endMessage, int seconds)
{
string tmpMessage = message + " ";
int count = 0;
while (count < seconds)
{
Strategy.THIS.Timeout(count++, () =>
{
ToScreen(tmpMessage + seconds--.ToString(CultureInfo.InvariantCulture));
});
}
Strategy.THIS.Timeout(count, () => ToScreen(endMessage));
}
public static void ToScreenCountDown(Player player, string message, string endMessage, int seconds)
{
string tmpMessage = message + " ";
int count = 0;
while (count < seconds)
{
Strategy.THIS.Timeout(count++, () =>
{
ToScreen(player, tmpMessage + seconds--.ToString(CultureInfo.InvariantCulture));
});
}
Strategy.THIS.Timeout(count, () => ToScreen(player, endMessage));
}
public static void ToScreenCountDown(int army, string message, string endMessage, int seconds)
{
string tmpMessage = message + " ";
int count = 0;
while (count < seconds)
{
Strategy.THIS.Timeout(count++, () =>
{
ToScreen(army, tmpMessage + seconds--.ToString(CultureInfo.InvariantCulture));
});
}
Strategy.THIS.Timeout(count, () => ToScreen(army, endMessage));
}
}
}
Code:
//$reference parts/core/COD.dll //reference to my dll (Assembly)
using System;
using maddox.game;
using maddox.game.world;
using COD; //My namespace
public class Mission : AMission
{
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
Message.ToChatbar(player, "Welcome {0}", player);
}
}
|
|
#2
|
|||
|
|||
|
Thank you very much! I will try your version later. |
|
#3
|
|||
|
|||
|
Not work
Code:
[22:50:10] ================================================= [22:50:10] System.IO.FileNotFoundException: Could not load file or assembly 'SMPlocalization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Не удается найти указанный файл. [22:50:10] File name: 'SMPlocalization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' [22:50:10] [22:50:10] Server stack trace: [22:50:10] at Mission.OnTickGame() [22:50:10] at maddox.game.ABattle.OnTickGame() [22:50:10] at maddox.game.world.Strategy.OnTickGame() [22:50:10] at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) [22:50:10] at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) [22:50:10] [22:50:10] Exception rethrown at [0]: [22:50:10] at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) [22:50:10] at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) [22:50:10] at maddox.game.IBattle.OnTickGame() [22:50:10] at maddox.game.GameDef.tickGame() [22:50:10] at Rnn9R0HNW1FFeT2aIDs.ltiVH2HK9YyK7SdiCrk.8IDxVdt1dPyeHPkw7Ndf(Object ) [22:50:10] at Rnn9R0HNW1FFeT2aIDs.ltiVH2HK9YyK7SdiCrk.NaqwoOS5Joc() [22:50:10] at JHVeKKyORf15WCVE1pL.eE20r2yPeQB95WctiCJ.ZRMSPQBwmiC(Boolean , Boolean ) [22:50:10] [22:50:10] WRN: Assembly binding logging is turned OFF. [22:50:10] To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [22:50:10] Note: There is some performance penalty associated with assembly bind failure logging. [22:50:10] To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [22:50:10] [22:50:10] ================================================= |
|
#4
|
|||
|
|||
|
Where do you store the file?
For multiplayer it must (should maybe there is another location too) be in "..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\core" at the moment, until we can create Addins and specify the path of the User Dlls in the xml-file. |
|
#5
|
|||
|
|||
|
I've been wondering about this, or how to modulise methods into individually run code when required.
What sort of restrictions is there at present for dll's? Actually how do you turn a cs script into a dll? Kodiak, I see also you run multible occurances of a public static void ToChatBar I thought this conflicted? How does it know which one to use? |
|
#6
|
|||
|
|||
|
Normally none.
Quote:
Quote:
|
|
#7
|
|||
|
|||
|
Quote:
|
|
#8
|
|||
|
|||
|
Addins for multiplayer are ignored at the moment or some trick is needed - ok if you get it to work tell me please.
|
|
#9
|
|||
|
|||
|
ok, I try to build project(your message above) but get errors, so add references of CLOD, then project won't build and create dll....hmmm
I tried to follow several guides on web, all say process much the same, but dont work because I seem to need references from CLOD, which seem to make the build step fail...sigh. doing something wrong, not sure what. |
![]() |
|
|