Skip to content

Commit

Permalink
fix: various small problem
Browse files Browse the repository at this point in the history
  • Loading branch information
samyycX committed Jan 11, 2025
1 parent 87923d1 commit aeeaea9
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions EnvManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CEnvSky>(index)!;
nint ptr = Helper.FindMaterialByPath("materials/notexist.vmat");
Expand Down
6 changes: 4 additions & 2 deletions Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.");
}


Expand Down
4 changes: 2 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace SkyboxChanger;
public class SkyboxChanger : BasePlugin, IPluginConfig<SkyboxConfig>
{
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();
Expand Down Expand Up @@ -124,7 +124,7 @@ public override unsafe void Load(bool hotReload)
RegisterListener<Listeners.OnClientDisconnect>(slot =>
{
EnvManager.OnPlayerLeave(slot);
Service.Save(Utilities.GetPlayerFromSlot(slot)?.AuthorizedSteamID?.SteamId64);
Service.Save(Utilities.GetPlayerFromSlot(slot)?.SteamID);
});
InitializeMenuSystem(hotReload);
Helper.Initialize();
Expand Down
16 changes: 8 additions & 8 deletions Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -34,38 +34,38 @@ 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);
}

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)
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit aeeaea9

Please sign in to comment.