From da484765b14b90bb1de0557e062046c854b31d64 Mon Sep 17 00:00:00 2001 From: B3none Date: Sun, 3 Mar 2024 17:19:38 +0000 Subject: [PATCH 1/4] Swapped weapon allocation to be next frame instead of with the timer method --- Modules/Managers/AllocationManager.cs | 2 -- RetakesPlugin.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/Managers/AllocationManager.cs b/Modules/Managers/AllocationManager.cs index e68984d..c6a8fef 100644 --- a/Modules/Managers/AllocationManager.cs +++ b/Modules/Managers/AllocationManager.cs @@ -35,7 +35,6 @@ private static void AllocateWeapons(CCSPlayerController player) if (player.Team == CsTeam.Terrorist) { player.GiveNamedItem(CsItem.AK47); - // player.GiveNamedItem(CsItem.Glock); player.GiveNamedItem(CsItem.Deagle); } @@ -51,7 +50,6 @@ private static void AllocateWeapons(CCSPlayerController player) player.GiveNamedItem(CsItem.M4A1S); } - // player.GiveNamedItem(CsItem.USPS); player.GiveNamedItem(CsItem.Deagle); } diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index bfeb881..792bba5 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -648,7 +648,7 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf player.RemoveWeapons(); // Create a timer to do this as it would occasionally fire too early. - AddTimer(0.05f, () => + Server.NextFrame(() => { if (!Helpers.IsValidPlayer(player)) { From 062092c38c17cc62e203fc666eee8732e22ef751 Mon Sep 17 00:00:00 2001 From: B3none Date: Sun, 3 Mar 2024 21:36:33 +0000 Subject: [PATCH 2/4] We no longer allocate weapons using a timer --- RetakesPlugin.cs | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index 792bba5..d2ffa5a 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -636,7 +636,7 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf Helpers.WriteLine($"{LogPrefix}Trying to loop valid active players."); foreach (var player in _gameManager.QueueManager.ActivePlayers.Where(Helpers.IsValidPlayer)) { - Helpers.WriteLine($"{LogPrefix}[{player.PlayerName}] Adding timer for allocation..."); + Helpers.WriteLine($"{LogPrefix}[{player.PlayerName}] Handling allocation..."); if (!Helpers.IsValidPlayer(player)) { @@ -646,34 +646,24 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf // Strip the player of all of their weapons and the bomb before any spawn / allocation occurs. Helpers.RemoveHelmetAndHeavyArmour(player); player.RemoveWeapons(); - - // Create a timer to do this as it would occasionally fire too early. - Server.NextFrame(() => + + if (player == _planter && RetakesConfig.IsLoaded(_retakesConfig) && + !_retakesConfig!.RetakesConfigData!.IsAutoPlantEnabled) { - if (!Helpers.IsValidPlayer(player)) - { - Helpers.WriteLine($"{LogPrefix}Allocating weapons: Player is not valid."); - return; - } - - if (player == _planter && RetakesConfig.IsLoaded(_retakesConfig) && - !_retakesConfig!.RetakesConfigData!.IsAutoPlantEnabled) - { - Helpers.WriteLine($"{LogPrefix}Player is planter and auto plant is disabled, allocating bomb."); - Helpers.GiveAndSwitchToBomb(player); - } + Helpers.WriteLine($"{LogPrefix}Player is planter and auto plant is disabled, allocating bomb."); + Helpers.GiveAndSwitchToBomb(player); + } - if (!RetakesConfig.IsLoaded(_retakesConfig) || - _retakesConfig!.RetakesConfigData!.EnableFallbackAllocation) - { - Helpers.WriteLine($"{LogPrefix}Allocating..."); - AllocationManager.Allocate(player); - } - else - { - Helpers.WriteLine($"{LogPrefix}Fallback allocation disabled, skipping."); - } - }); + if (!RetakesConfig.IsLoaded(_retakesConfig) || + _retakesConfig!.RetakesConfigData!.EnableFallbackAllocation) + { + Helpers.WriteLine($"{LogPrefix}Allocating..."); + AllocationManager.Allocate(player); + } + else + { + Helpers.WriteLine($"{LogPrefix}Fallback allocation disabled, skipping."); + } } return HookResult.Continue; From 632b2ef07649f3b5125c6fe889d28cd12792b01b Mon Sep 17 00:00:00 2001 From: B3none Date: Sun, 3 Mar 2024 21:42:13 +0000 Subject: [PATCH 3/4] Added TODO --- RetakesPlugin.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index d2ffa5a..2824d02 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -663,6 +663,8 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf else { Helpers.WriteLine($"{LogPrefix}Fallback allocation disabled, skipping."); + + // TODO: Once shared apis are implemented into CounterStrikeSharp then notify allocators to allocate. } } From ad4c4966aa53658c46b7ae3694b2e82f91bc3bd2 Mon Sep 17 00:00:00 2001 From: B3none Date: Sun, 3 Mar 2024 21:52:33 +0000 Subject: [PATCH 4/4] Bumped version to 1.3.31 --- RetakesPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RetakesPlugin.cs b/RetakesPlugin.cs index 2824d02..1221d8e 100644 --- a/RetakesPlugin.cs +++ b/RetakesPlugin.cs @@ -17,7 +17,7 @@ namespace RetakesPlugin; [MinimumApiVersion(154)] public class RetakesPlugin : BasePlugin { - private const string Version = "1.3.30"; + private const string Version = "1.3.31"; #region Plugin info public override string ModuleName => "Retakes Plugin";