Skip to content

Starting 1 (Plugin.cs)

SebasCapo edited this page May 29, 2020 · 2 revisions

After creating a new project/solution and importing every dependency, you'll have an empty class (By default called Class1.cs, most EXILED-devs call this class "Plugin.cs"), which I will rename to MyPlugin.

If things are okay, it should look something like this:

using System;

namespace SamplePlugin
{
	public class MyPlugin
	{
	}
}

Currently, our class is just a regular CSharp class, but for it to have all the different properties a plugin has, we will make it inherit the plugin interface by doing this:

using System;

namespace SamplePlugin
{
	public class MyPlugin : EXILED.Plugin
	{
	}
}

Now, we should see an error, don't worry, this is your editor saying that you need the basic stuff a plugin has, so we will add all the different methods inside our class:

using System;

namespace SamplePlugin
{
	public class MyPlugin : EXILED.Plugin
	{
		// This method is fired after a round ends, a server is closing and restarting.
		public override void OnDisable()
		{
			
		}

		// This method is fired during plugin loading.
		public override void OnEnable()
		{
			
		}

		// This is only fired when you use the EXILED reload command, the reload command will call OnDisable, OnReload, reload the plugin, then OnEnable in that order. There is no GAC bypass, so if you are updating a plugin, it must have a unique assembly name, and you need to remove the old version from the plugins folder. This method is not usually used though, since you will probably want to use OnEnable.
		public override void OnReload()
		{
			
		}

		// This is the plugin's name, though usually your assembly name is used.
		// Also, this is a variable, not a method, but since we don't want to change the plugin name during any of the events, we only want to get the name, not change it. (If for some reason you do want to, just do getName = "Your plugin's name here";
		public override string getName { get; } = "Incredible & amazing, sample plugin";
	}
}

Now, the plugin should be technically ready to be used, but we want to give it some other functions, we will get started on the events-handling class in next page.

Clone this wiki locally