You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
usingSynapse.Api;usingSynapse.Api.Plugin;namespaceFirstPlugin{[PluginInformation(Name="FirstPlugin",//The Name of Your PluginAuthor="Dimenzio",// Your NameDescription="My First Awesome Plugin",// A Description for your PluginLoadPriority=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)]publicclassPluginClass:AbstractPlugin{publicoverridevoidLoad(){Logger.Get.Info("Hello World");SynapseController.Server.Events.Player.PlayerLeaveEvent+=OnLeave;}publicvoidOnLeave(Synapse.Api.Events.SynapseEventArguments.PlayerLeaveEventArgsev){Map.Get.SendBroadcast(5,"A Player left the Server");}}}