Beispiel #1
0
        public override void OnEnabled()
        {
            base.OnEnabled();
            try
            {
                Log.Debug("Initializing event handlers for King's SCPSL....");

                //Set instance varible to a new instance, this should be nulled again in OnDisable
                PlayerEvents = new PlayerEvents(this);
                ServerEvents = new ServerEvents(this);

                //Hook the events you will be using in the plugin. You should hook all events you will be using here, all events should be unhooked in OnDisabled
                Handlers.Player.Joined                    += PlayerEvents.OnPlayerConnect;
                Handlers.Player.Left                      += PlayerEvents.OnPlayerDisconnect;
                Handlers.Player.Hurting                   += PlayerEvents.OnPlayerHurt;
                Handlers.Player.Banning                   += PlayerEvents.OnPreBan;
                Handlers.Player.Banned                    += PlayerEvents.OnPlayerBanned;
                Handlers.Player.PreAuthenticating         += PlayerEvents.OnPreAuth;
                Handlers.Player.Kicking                   += PlayerEvents.OnPreKick;
                Handlers.Server.RoundStarted              += ServerEvents.OnRoundStart;
                Handlers.Server.RoundEnded                += ServerEvents.OnRoundEnd;
                Handlers.Server.WaitingForPlayers         += ServerEvents.WaitingForPlayers;
                Handlers.Server.RespawningTeam            += ServerEvents.OnTeamRespawn;
                Handlers.Server.SendingRemoteAdminCommand += PlayerEvents.OnCommand;
                Handlers.Server.SendingConsoleCommand     += PlayerEvents.OnConsoleCommand;

                Log.Info($"KingsSCPSL plugin loaded. Written by Thomasjosif");
            }
            catch (Exception e)
            {
                //This try catch is redundant, as EXILED will throw an error before this block can, but is here as an example of how to handle exceptions/errors
                Log.Error($"There was an error loading the plugin: {e}");
            }
        }
Beispiel #2
0
        public override void OnDisabled()
        {
            base.OnDisabled();

            Handlers.Player.Joined            -= PlayerEvents.OnPlayerConnect;
            Handlers.Player.Left              -= PlayerEvents.OnPlayerDisconnect;
            Handlers.Player.Hurting           -= PlayerEvents.OnPlayerHurt;
            Handlers.Player.Banned            -= PlayerEvents.OnPlayerBanned;
            Handlers.Player.PreAuthenticating -= PlayerEvents.OnPreAuth;

            Handlers.Server.RoundStarted              -= ServerEvents.OnRoundStart;
            Handlers.Server.RoundEnded                -= ServerEvents.OnRoundEnd;
            Handlers.Server.WaitingForPlayers         -= ServerEvents.WaitingForPlayers;
            Handlers.Server.RespawningTeam            -= ServerEvents.OnTeamRespawn;
            Handlers.Server.SendingRemoteAdminCommand -= PlayerEvents.OnCommand;
            Handlers.Server.SendingConsoleCommand     -= PlayerEvents.OnConsoleCommand;

            PlayerEvents = null;
            ServerEvents = null;
        }