diff --git a/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj b/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj index 2e9ac3b6..e72b61d9 100644 --- a/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj +++ b/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj @@ -12,6 +12,9 @@ + + ..\..\public\Jailbreak.Public\Mixin\GangsAPI.dll + ..\..\public\Jailbreak.Public\Mixin\MStatsShared.dll diff --git a/mod/Jailbreak.LastRequest/LastRequestManager.cs b/mod/Jailbreak.LastRequest/LastRequestManager.cs index 78b24f72..91869ed7 100644 --- a/mod/Jailbreak.LastRequest/LastRequestManager.cs +++ b/mod/Jailbreak.LastRequest/LastRequestManager.cs @@ -5,6 +5,8 @@ using CounterStrikeSharp.API.Modules.Cvars.Validators; using CounterStrikeSharp.API.Modules.Menu; using CounterStrikeSharp.API.Modules.Utils; +using GangsAPI.Data; +using GangsAPI.Services; using Jailbreak.Formatting.Extensions; using Jailbreak.Formatting.Views.LastRequest; using Jailbreak.Public; @@ -105,6 +107,19 @@ public void EnableLR(CCSPlayerController? died = null) { if (died != null && player.SteamID == died.SteamID) continue; player.ExecuteClientCommandFromServer("css_lr"); } + + if (API.Gangs != null) { + var eco = API.Gangs.Services.GetService(); + if (eco == null) return; + var survivors = Utilities.GetPlayers() + .Where(p => p is { IsBot: false, PawnIsAlive: true }) + .Select(p => new PlayerWrapper(p)) + .ToList(); + Task.Run(async () => { + foreach (var survivor in survivors) + await eco.Grant(survivor, 100, reason: "LR Reached"); + }); + } } public bool InitiateLastRequest(CCSPlayerController prisoner, @@ -137,6 +152,18 @@ public bool EndLastRequest(AbstractLastRequest lr, LRResult result) { if (result is LRResult.GUARD_WIN or LRResult.PRISONER_WIN) { RoundUtil.AddTimeRemaining(CV_LR_BONUS_TIME.Value); messages.LastRequestDecided(lr, result).ToAllChat(); + + if (API.Gangs != null) { + var eco = API.Gangs.Services.GetService(); + if (eco == null) return false; + var wrapper = + new PlayerWrapper(result == LRResult.GUARD_WIN ? + lr.Guard : + lr.Prisoner); + Task.Run(async () => { + await eco.Grant(wrapper, 30, reason: "LR Win"); + }); + } } API.Stats?.PushStat(new ServerStat("JB_LASTREQUEST_RESULT", @@ -192,14 +219,7 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) { if (!IsLREnabledForRound) return HookResult.Continue; if (player.Team != CsTeam.Terrorist) return HookResult.Continue; - - if (countAlivePrisoners() - 1 > CV_PRISONER_TO_LR.Value) - return HookResult.Continue; - - if (Utilities.GetPlayers().All(p => p.Team != CsTeam.CounterTerrorist)) - return HookResult.Continue; - - EnableLR(player); + checkLR(); return HookResult.Continue; } @@ -226,13 +246,20 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, if (!IsLREnabledForRound) return HookResult.Continue; if (player.Team != CsTeam.Terrorist) return HookResult.Continue; - if (countAlivePrisoners() > CV_PRISONER_TO_LR.Value) - return HookResult.Continue; - EnableLR(); + checkLR(); return HookResult.Continue; } + private void checkLR() { + Server.NextFrame(() => { + if (Utilities.GetPlayers().All(p => p.Team != CsTeam.CounterTerrorist)) + return; + if (countAlivePrisoners() > CV_PRISONER_TO_LR.Value) return; + EnableLR(); + }); + } + private int countAlivePrisoners() { return Utilities.GetPlayers().Count(prisonerCountsToLR); } diff --git a/mod/Jailbreak.Rebel/C4Bomb/C4Behavior.cs b/mod/Jailbreak.Rebel/C4Bomb/C4Behavior.cs index e342981f..480e22f6 100644 --- a/mod/Jailbreak.Rebel/C4Bomb/C4Behavior.cs +++ b/mod/Jailbreak.Rebel/C4Bomb/C4Behavior.cs @@ -7,6 +7,7 @@ using CounterStrikeSharp.API.Modules.Utils; using Gangs.BombIconPerk; using GangsAPI.Data; +using GangsAPI.Services; using GangsAPI.Services.Gang; using GangsAPI.Services.Player; using Jailbreak.Formatting.Extensions; @@ -267,6 +268,15 @@ private void detonate(CCSPlayerController player, CC4 bomb) { } } + if (API.Gangs != null) { + var eco = API.Gangs.Services.GetService(); + if (eco != null) { + var wrapper = new PlayerWrapper(player); + Task.Run(async () + => await eco.Grant(wrapper, killed * 50, reason: "C4 Kill")); + } + } + API.Stats?.PushStat(new ServerStat("JB_BOMB_EXPLODED", killed.ToString())); // If they didn't have the C4 make sure to remove it.