Synapse
Search
⌃K

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",
Author = "Dimenzio",
Description = "My First Awesome Plugin",
LoadPriority = 0,
SynapseMajor = 2,
SynapseMinor = 7,
SynapsePatch = 0,
Version = "v.1.0.0"
)]
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: