Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.
GrafDimenzio edited this page Jan 9, 2021 · 6 revisions

Events

If you want to execute your code when something happen you can hook a method to an Event.

In order to do this you need the use the EventHandler object which you can get with SynapseController.Server.Events or Synapse.Api.Events.EventHandler.Get

In this object are different types of Events:

  • Server => All Events which has something to do with the Server
  • Player => All Events which has something to do with a Player
  • Round => All Events which has something to do with the Round
  • Map => All Events which has something to do with the Map
  • Scp => All Events which has something to do with the Scp's.

Example:

using Synapse.Api;
using Synapse.Api.Plugin;

namespace FirstPlugin
{
    [PluginInformation(
        Name = "FirstPlugin", //The Name of Your Plugin
        Author = "Dimenzio", // Your Name
        Description = "My First Awesome Plugin", // A Description for your Plugin
        LoadPriority = 0, //When your Plugin should get loaded (use 0 if you don't know how to use it)
        SynapseMajor = 2, //The Synapse Version for which this Plugin was created for (SynapseMajor.SynapseMinor.SynapsePatch => 2.4.1)
        SynapseMinor = 4,
        SynapsePatch = 1,
        Version = "v.1.0.0" //The Current Version of your Plugin
        )]
    public class PluginClass : AbstractPlugin
    {
        public override void Load()
        {
            Logger.Get.Info("Hello World");
            SynapseController.Server.Events.Player.PlayerLeaveEvent += OnLeave;
        }

        public void OnLeave(Synapse.Api.Events.SynapseEventArguments.PlayerLeaveEventArgs ev)
        {
            Map.Get.SendBroadcast(5,"A Player left the Server");
        }
    }
}

Next-Step is to look into the Config and Translation system.

Clone this wiki locally