Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 05-21-2012, 10:10 AM
podvoxx podvoxx is offline
Approved Member
 
Join Date: Feb 2010
Posts: 190
Default How add user dll

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;
        }
    }
}
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 : 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");       
    }
In this code I have error on game(Exception). How I can use method localization.locText()?

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");       
    }
Maybe someone has a ready example of a simple dll?
Reply With Quote
  #2  
Old 05-21-2012, 10:41 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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));
        }

    }
}
In the script file i use

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);
       
        
    }
}
Reply With Quote
  #3  
Old 05-21-2012, 12:00 PM
podvoxx podvoxx is offline
Approved Member
 
Join Date: Feb 2010
Posts: 190
Default

Quote:
Originally Posted by FG28_Kodiak View Post
For example i use this in my dll:

Thank you very much! I will try your version later.
Reply With Quote
  #4  
Old 05-21-2012, 07:09 PM
podvoxx podvoxx is offline
Approved Member
 
Join Date: Feb 2010
Posts: 190
Default

Not work , I have this error whith your code:

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]	=================================================
Reply With Quote
  #5  
Old 05-21-2012, 09:21 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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.
Reply With Quote
  #6  
Old 05-21-2012, 11:12 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

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?
Reply With Quote
  #7  
Old 05-22-2012, 06:26 AM
podvoxx podvoxx is offline
Approved Member
 
Join Date: Feb 2010
Posts: 190
Default

Quote:
Originally Posted by FG28_Kodiak View Post
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.
My folder in "..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\MyDLLfolder". In the evening try to change the folder location and add xml-file.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:48 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.