Wiki

Clone wiki

Arma2NET / Tutorial

Tutorial

This simple tutorial will guide you to making your own plugin and then calling it from SQF code.

Creating a new project

First, create a new class library project using your favourite .NET language. For this tutorial we will be using C# and Visual Studio to create a plugin that reverses text.

tut1.png

Your window should look something like this:

tut2.png

Adding the references

Add a reference to Arma2Net.AddInProxy.dll. Right click References in your Solution Explorer and click Add Reference.

tut3.png

You can remove the references that were already there such as System.Data, because we don't need them.

Creating the plugin

Decorate your plugin class with Arma2Net.AddInProxy.AddInAttribute, specifying the function name as the name argument. For this plugin we will be using "ReverseText".

The plugin class needs to inherit from Arma2Net.AddInProxy.AddIn and override the Invoke method. This method is what will expose the functionality of the plugin.

Now go ahead and implement the plugin. Since we are reversing text we'll probably want to use the System.Linq.Enumerable.Reverse and System.String.Concat methods.

tut4.png

Go ahead and build the project. You'll probably want to use the Release configuration. Now to test the plugin.

Running the plugin

Head to your Release directory, or wherever you built your project. Create a folder inside ArmA 2\@Arma2NET\AddIns with the name of the plugin. Copy your built .dll file into the directory.

tut5.png

You can now call your plugin from Arma 2. For this particular tutorial we will be hinting the result of reversing the text.

hint ("Arma2Net.Unmanaged" callExtension "ReverseText hello world")

SqfCallExtension.png

Click Preview. The game hints "dlrow olleh" to the screen.

SqfResult.png

That's it! Check out the Plugin writing page for more information about writing plugins, and the Using Arma2NET page for more information about using Arma2NET.

Updated