diff --git a/EnvManager.cs b/EnvManager.cs index 3e23feb..816f532 100644 --- a/EnvManager.cs +++ b/EnvManager.cs @@ -35,6 +35,7 @@ public unsafe void InitializeSkyboxForPlayer(CCSPlayerController player) public unsafe void OnPlayerLeave(int slot) { + if (!SpawnedSkyboxes.ContainsKey(slot)) return; var index = SpawnedSkyboxes[slot]; CEnvSky sky = Utilities.GetEntityFromIndex(index)!; nint ptr = Helper.FindMaterialByPath("materials/notexist.vmat"); diff --git a/Memory.cs b/Memory.cs index b764f4e..07fccc2 100644 --- a/Memory.cs +++ b/Memory.cs @@ -4,7 +4,8 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; -using SkyboxChanger; + +namespace SkyboxChanger; class MemoryManager { @@ -92,7 +93,8 @@ private static unsafe IntPtr FindSpawnGroupMgrGameSystem() pFactoryList = pNext; } - throw new Exception("FAILED TO FIND SpawnGroupManagerGameSystem. The game ma y have been updated, please report it to the author."); + + throw new Exception("FAILED TO FIND SpawnGroupManagerGameSystem. The game may have been updated, please report it to the author."); } diff --git a/Plugin.cs b/Plugin.cs index 5239f04..95a8ced 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -17,7 +17,7 @@ namespace SkyboxChanger; public class SkyboxChanger : BasePlugin, IPluginConfig { public override string ModuleName => "Skybox Changer"; - public override string ModuleVersion => "1.3.0"; + public override string ModuleVersion => "1.3.1"; public override string ModuleAuthor => "samyyc"; public SkyboxConfig Config { get; set; } = new(); @@ -124,7 +124,7 @@ public override unsafe void Load(bool hotReload) RegisterListener(slot => { EnvManager.OnPlayerLeave(slot); - Service.Save(Utilities.GetPlayerFromSlot(slot)?.AuthorizedSteamID?.SteamId64); + Service.Save(Utilities.GetPlayerFromSlot(slot)?.SteamID); }); InitializeMenuSystem(hotReload); Helper.Initialize(); diff --git a/Service.cs b/Service.cs index c1438a7..4ec404b 100644 --- a/Service.cs +++ b/Service.cs @@ -17,12 +17,12 @@ public Service(SkyboxChanger plugin, string host, int port, string user, string public bool SetSkybox(CCSPlayerController player, string index) { - _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Skybox = index; + _Storage.GetPlayerSkydata(player.SteamID).Skybox = index; Skybox skybox = _Plugin.Config.Skyboxs[index]; if (skybox.Brightness != null) { _Plugin.EnvManager.SetBrightness(player.Slot, skybox.Brightness.Value); - _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Brightness = skybox.Brightness.Value; + _Storage.GetPlayerSkydata(player.SteamID).Brightness = skybox.Brightness.Value; } if (skybox.Color != null) { @@ -34,7 +34,7 @@ public bool SetSkybox(CCSPlayerController player, string index) var b = int.Parse(colorData[2]); var a = int.Parse(colorData[3]); _Plugin.EnvManager.SetTintColor(player.Slot, Color.FromArgb(a, r, g, b)); - _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Color = Color.FromArgb(a, r, g, b).ToArgb(); + _Storage.GetPlayerSkydata(player.SteamID).Color = Color.FromArgb(a, r, g, b).ToArgb(); } } return _Plugin.EnvManager.SetSkybox(player.Slot, skybox); @@ -42,30 +42,30 @@ public bool SetSkybox(CCSPlayerController player, string index) public void SetBrightness(CCSPlayerController player, float brightness) { - _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Brightness = brightness; + _Storage.GetPlayerSkydata(player.SteamID).Brightness = brightness; _Plugin.EnvManager.SetBrightness(player.Slot, brightness); } public void SetTintColor(CCSPlayerController player, Color color) { - _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Color = color.ToArgb(); + _Storage.GetPlayerSkydata(player.SteamID).Color = color.ToArgb(); _Plugin.EnvManager.SetTintColor(player.Slot, color); } public Skybox? GetPlayerSkybox(CCSPlayerController player) { - var skyboxData = _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64); + var skyboxData = _Storage.GetPlayerSkydata(player.SteamID); return _Plugin.Config.Skyboxs.GetValueOrDefault(skyboxData.Skybox); } public float GetPlayerBrightness(CCSPlayerController player) { - return _Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Brightness; + return _Storage.GetPlayerSkydata(player.SteamID).Brightness; } public Color GetPlayerColor(CCSPlayerController player) { - return Color.FromArgb(_Storage.GetPlayerSkydata(player.AuthorizedSteamID!.SteamId64).Color); + return Color.FromArgb(_Storage.GetPlayerSkydata(player.SteamID).Color); } public Skybox? GetMapDefaultSkybox(string map) diff --git a/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.dll b/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.dll index 8711b7f..9633c36 100644 Binary files a/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.dll and b/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.dll differ diff --git a/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.pdb b/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.pdb index 9cfa309..5785213 100644 Binary files a/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.pdb and b/build/addons/counterstrikesharp/plugins/SkyboxChanger/SkyboxChanger.pdb differ