Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WeaponPaints usage for fallback allocation #84

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Modules/Managers/AllocationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -51,7 +50,6 @@ private static void AllocateWeapons(CCSPlayerController player)
player.GiveNamedItem(CsItem.M4A1S);
}

// player.GiveNamedItem(CsItem.USPS);
player.GiveNamedItem(CsItem.Deagle);
}

Expand Down
48 changes: 20 additions & 28 deletions RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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))
{
Expand All @@ -646,34 +646,26 @@ 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.
AddTimer(0.05f, () =>
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.");

// TODO: Once shared apis are implemented into CounterStrikeSharp then notify allocators to allocate.
}
}

return HookResult.Continue;
Expand Down
Loading