-
Notifications
You must be signed in to change notification settings - Fork 9
event handler
mtanksl edited this page Dec 11, 2023
·
4 revisions
Commands
may generate events
, which can be listened by Event Handlers
.
Let's listen to the PlayerLoginEventArgs
, which occurs when any player logs in the game.
public class PlayerLoginScripts : Script
{
private Guid playerLogin;
public override void Start()
{
playerLogin = Context.Server.EventHandlers.Subscribe<PlayerLoginEventArgs>( (context, e) =>
{
Context.Server.Logger.WriteLine(e.Player.Name + " login.", LogLevel.Information);
return Promise.Completed;
} );
}
public override void Stop()
{
Context.Server.EventHandlers.Unsubscribe<PlayerLoginEventArgs>(playerLogin);
}
}