-
Notifications
You must be signed in to change notification settings - Fork 0
Starting 1 (Plugin.cs)
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()
{
// Will leave a message to see when the plugin is being disabled. This is not 100% necessary, though getting used to debugging is important.
Log.Info("Bye world :(");
}
// This method is fired during plugin loading.
public override void OnEnable()
{
// Will leave a message to see when the plugin is being enabled. Again, this is not 100% necessary.
Log.Info("Hello world :D");
}
// 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()
{
// In case you want to see when OnReload is fired.
Log.Info("Hello world?");
}
// 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 this instead: public override string 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.