Making a Plugin

RAGE Plugin Hook Documentation

[This is preliminary documentation and is subject to change.]

Plugins can be written in any CLI-compliant language, including (but not limited to) the following:

If you do not know any of these languages, we recommend you learn C#.

We recommend using an IDE like Visual Studio to develop plugins.
If you do not have an IDE, you can download Visual Studio Community for free from Microsoft.

Once you know any of these languages, and have installed Visual Studio, you're ready to create your first plugin.

Creating a new plugin project

  1. Start Visual Studio.

  2. Open the File menu, select New, and then Project.

  3. In the New Project dialog, choose Visual C# or other prefered, CLI-compliant language. Then choose Class Library, give it a name, and choose .NET Framework 4.5.1.
    New Project Class Library

You will now have a new empty C# Class Library project. The first thing to do is add RAGEPluginHookSDK.dll as a reference.

Next, we'll have to define an entry point for our plugin. But before we do, let's rename the default file and class from Class1 to EntryPoint.
When RAGE Plugin Hook loads your plugin, it looks through all the types in the plugin for a static method called Main.
It will choose the first static Main method as the entry point. The name of the class is not important, however the name EntryPoint is fitting.

The Main method must have the following signature:

static void Main()

You can also specify a custom name for the entry point method by setting the EntryPoint property of the Plugin attribute.

After defining this method, you should now have something that looks like this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFirstPlugin
{
    public static class EntryPoint
    {
        public static void Main()
        {
        }
    }
}

Now that we've defined an entry point for our plugin, there's only one more thing we need to be able to load this plugin into RAGE Plugin Hook.

Each plugin must contain the PluginAttribute assembly attribute, providing RAGE Plugin Hook with some information about the plugin.
RAGE Plugin Hook will refuse to load a plugin that doesn't define this assembly attribute.

After adding this attribute, your code should look something like this:

[assembly: Rage.Attributes.Plugin("My First Plugin", Description = "This is my first plugin.", Author = "MyName")]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFirstPlugin
{
    public static class EntryPoint
    {
        public static void Main()
        {
        }
    }
}

You now have a plugin that can be loaded by RAGE Plugin Hook.
Plugins are automatically unloaded once the Main method returns.