diff --git a/hats/Config.cs b/hats/Config.cs index 1175170..9a9f1db 100644 --- a/hats/Config.cs +++ b/hats/Config.cs @@ -24,6 +24,13 @@ public class Config : IConfig RoleType.Scp096 }; + public bool EnableAutoGiveHat { get; set; } = false; + [Description("Roles that will be given a hat on spawn, if EnableAutoGiveHat is true")] + public Dictionary RolesWithHats { get; set; } = new Dictionary() + { + [RoleType.ClassD] = "Name", + }; + public List Hats { get; set; }= new List() { new HatConfig() diff --git a/hats/EventHandler.cs b/hats/EventHandler.cs index 790cc55..350088d 100644 --- a/hats/EventHandler.cs +++ b/hats/EventHandler.cs @@ -5,6 +5,7 @@ namespace hats { using Exiled.API.Enums; + using Exiled.API.Features; public class EventHandler { @@ -49,5 +50,19 @@ public void UsedItem(UsedItemEventArgs ev) ev.Player.ShowHint("Removed hat since you used 268."); } } + + public void Spawned(SpawnedEventArgs ev) + { + if (!cfg.EnableAutoGiveHat) + return; + if (!cfg.RolesWithHats.ContainsKey(ev.Player.Role.Type)) + return; + if(!API.Hats.ContainsKey(cfg.RolesWithHats[ev.Player.Role.Type])) + { + Log.Warn($"Could not find hat: {cfg.RolesWithHats[ev.Player.Role.Type]} for role: {ev.Player.Role.Type}"); + return; + } + ev.Player.AddHat(API.Hats[cfg.RolesWithHats[ev.Player.Role.Type]]); + } } } \ No newline at end of file diff --git a/hats/Plugin.cs b/hats/Plugin.cs index 0bcca29..b3bb086 100644 --- a/hats/Plugin.cs +++ b/hats/Plugin.cs @@ -11,7 +11,7 @@ public class Plugin : Plugin { public override string Author { get; } = "Rowpann SCP"; public override string Name { get; } = "hats"; - public override Version Version { get; } = new Version(1, 4, 3); + public override Version Version { get; } = new Version(1, 5, 0); public override Version RequiredExiledVersion { get; } = new Version(5, 2, 0); public static Plugin Singleton; @@ -28,6 +28,7 @@ public override void OnEnabled() Player.Left += Handler.OnLeave; Player.Died += Handler.Died; Player.UsedItem += Handler.UsedItem; + Player.Spawned += Handler.Spawned; base.OnEnabled(); } @@ -38,6 +39,7 @@ public override void OnDisabled() Player.Left -= Handler.OnLeave; Player.Died -= Handler.Died; Player.UsedItem -= Handler.UsedItem; + Player.Spawned -= Handler.Spawned; Singleton = null; Handler = null;