Hey, so like me you want the ability to do more with ARMA but C++ is not one of your favorite languages, here is a small tutorial on how to write a working ARMA DLL completely in C# (and other .NET languages I presume), no need for C++/CLR or ARMA2NET.
First, if you have not got it already, download Visual Studio Community 2013 from here: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
Once installed, start a new C# “Class Library” project.
Next step is to download a NuGet Package called “Unmanaged Exports“. To do this goto the menu “Project -> Manage NuGet Packages”, once the dialog opens, search for “Unmanaged Exports”, install it and close the dialog.
Now, the project is setup and you are ready to writing some code. Here is the most basic of examples (Download link below).
The class itself can be called anything, DllEntry seems appropriate. Once you compile the code, the RVExtension gets called whenever you execute a callExtension. In the SQF code below, the function string, is available via the function param in RVExtension. (I had a string encoding issue, i thought maybe marshaling would help…not sure…).
_output = "dllname" callExtension "function"; // _output == "noitcnuf"
Before you can compile, the Unmanaged Exports requires the projects “Platform Target” to be set to either x86 or x64 (I suggest x86 if you are not sure). To do this right click on the project and select “Properties”, click the “Build” section and change the “Platform Target” dropdown.
Now compile the project and put the resulting DLL into an ARMA mod folder. (Eg. @armaExtCS). Thats it, to run it in ARMA just execute this:
_output = "ARMAExtCS" callExtension "function";
What is the outputSize–; for?
Reduces the output size value by 1
Well yeah that’s a given lol… I’m asking what’s the purpose of doing this?
To ensure the output text doesn’t overflow and cause a crash. Its more of a “just in case” kinda thing
Hello,
I’m german so my english is very bad.
I’m making scripts for Arma 3 in sqf, so I have a folder with a mission.sqm file. In the same folder, I had to copy the .dll file from the .cs project. So I have actually a mission.sqm file and my ARMAExtCS.dll file.
Now I started Arma 3 -> Editor -> load my mission and wrote the same code in my debug console, but it didn’t work.
Maybe you understood what I tried to write and maybe you can help me.
Dr. Prof. Evil aka Tom
Once you have compiled the dll, to call it, you need to place is in ARMA root folder (not great) or in a @mod folder.
Then do:
"ARMAExtCS" callExtension "test";
Is there a way to put the extension in the mission file that is downloaded?
No, dlls have to be either in a @mod folder or in the root of ARMA (i dont recommend this way)