diff --git a/Events.cs b/Events.cs index 9efda73c..bc2b5462 100644 --- a/Events.cs +++ b/Events.cs @@ -1,5 +1,6 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Entities; namespace WeaponPaints { @@ -8,17 +9,17 @@ public partial class WeaponPaints private void RegisterEvents() { RegisterListener(OnEntitySpawned); - /*RegisterListener(OnClientAuthorized);*/ + RegisterListener(OnClientAuthorized); RegisterListener(OnClientDisconnect); RegisterListener(OnMapStart); - RegisterEventHandler(OnPlayerConnectFull); + //RegisterEventHandler(OnPlayerConnectFull); RegisterEventHandler(OnPlayerSpawn); RegisterEventHandler(OnRoundStart, HookMode.Pre); RegisterEventHandler(OnEventItemPurchasePost); RegisterEventHandler(OnItemPickup); } - private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info) + /*private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info) { CCSPlayerController? player = @event.Userid; @@ -29,17 +30,16 @@ private HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventI _ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex); if (Config.Additional.KnifeEnabled && weaponSync != null) _ = weaponSync.GetKnifeFromDatabase(playerIndex); - /* + Task.Run(async () => { if (Config.Additional.SkinEnabled && weaponSync != null) if (Config.Additional.KnifeEnabled && weaponSync != null) }); - */ return HookResult.Continue; } - + */ private void OnMapStart(string mapName) { if (!Config.Additional.KnifeEnabled) return; @@ -52,10 +52,22 @@ private void OnMapStart(string mapName) NativeAPI.IssueServerCommand("mp_equipment_reset_rounds 0"); }); } - /* + private void OnClientAuthorized(int playerSlot, SteamID steamID) { int playerIndex = playerSlot + 1; + + CCSPlayerController? player = Utilities.GetPlayerFromIndex(playerIndex); + + if (player == null || !player.IsValid || player.IsHLTV) return; + + if (Config.Additional.SkinEnabled && weaponSync != null) + _ = weaponSync.GetWeaponPaintsFromDatabase(playerIndex); + if (Config.Additional.KnifeEnabled && weaponSync != null) + _ = weaponSync.GetKnifeFromDatabase(playerIndex); + + + /* Task.Run(async () => { if (Config.Additional.SkinEnabled && weaponSync != null) @@ -63,8 +75,9 @@ private void OnClientAuthorized(int playerSlot, SteamID steamID) if (Config.Additional.KnifeEnabled && weaponSync != null) await weaponSync.GetKnifeFromDatabase(playerIndex); }); + */ } - */ + private void OnClientDisconnect(int playerSlot) { CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot); diff --git a/WeaponPaints.csproj b/WeaponPaints.csproj index 5db828f3..ee25d9f5 100644 --- a/WeaponPaints.csproj +++ b/WeaponPaints.csproj @@ -8,8 +8,8 @@ - - + +