-
-
Notifications
You must be signed in to change notification settings - Fork 10
event handler
mtanksl edited this page Jun 23, 2024
·
9 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(playerLogin);
}
}