![]() |
|
#1
|
|||
|
|||
![]()
I need to transfer the same parts of the code, which often use in dll-file in the game. For example the code localization(to send messages) and use of global variables in the hostmission and submission scripts. One file will be used in different scripts.
For example code of my dll-file: Code:
using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using maddox.game; using maddox.game.world; using maddox.GP; using part; namespace locfiledll { public class localization : AMission { public static int locText(int number1, int number2) { int result = number1 + number2; return result; } } } Code:
//$reference "P11_folder\P11_localization.dll" using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using maddox.game; using maddox.game.world; using maddox.GP; using locfiledll; public class Mission : localization { public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; int xxx = localization.locText(1, 2); //SendMessageToAll("Расчет из DLL = " + xxx.ToString(), "Chat"); //LOAD MAIN MISSION MAP OBJEKTS //GamePlay.gpPostMissionLoad("missions\\SMP\\Friday on my mind\\submissions\\Map AAA\\Map AAA.mis"); } And can I use this code: [/CODE] My mission script: Code:
//$reference "P11_folder\P11_localization.dll" using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using maddox.game; using maddox.game.world; using maddox.GP; using locfiledll; public class Mission : AMission { public override void OnBattleStarted() { base.OnBattleStarted(); MissionNumberListener = -1; int xxx = localization.locText(1, 2); //SendMessageToAll("Расчет из DLL = " + xxx.ToString(), "Chat"); //LOAD MAIN MISSION MAP OBJEKTS //GamePlay.gpPostMissionLoad("missions\\SMP\\Friday on my mind\\submissions\\Map AAA\\Map AAA.mis"); } |
#2
|
|||
|
|||
![]()
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); } } |
#3
|
|||
|
|||
![]() Thank you very much! I will try your version later. |
#4
|
|||
|
|||
![]()
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] ================================================= |
#5
|
|||
|
|||
![]()
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. |
#6
|
|||
|
|||
![]()
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? |
#7
|
|||
|
|||
![]() Quote:
|
![]() |
|
|