From e718016e173711c66fb6d4e5855c85b2f47990a5 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 23 Aug 2024 23:36:55 -0700 Subject: [PATCH] Dont generate spawns on SD or if invulnerable --- mod/Jailbreak.Zones/RandomZoneGenerator.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mod/Jailbreak.Zones/RandomZoneGenerator.cs b/mod/Jailbreak.Zones/RandomZoneGenerator.cs index 03bdb1d9..32232753 100644 --- a/mod/Jailbreak.Zones/RandomZoneGenerator.cs +++ b/mod/Jailbreak.Zones/RandomZoneGenerator.cs @@ -3,14 +3,16 @@ using CounterStrikeSharp.API.Modules.Timers; using Jailbreak.Public.Behaviors; using Jailbreak.Public.Extensions; +using Jailbreak.Public.Mod.SpecialDay; using Jailbreak.Public.Mod.Zones; using Jailbreak.Public.Utils; +using Microsoft.Extensions.DependencyInjection; using Timer = CounterStrikeSharp.API.Modules.Timers.Timer; namespace Jailbreak.Zones; -public class RandomZoneGenerator(IZoneManager zoneManager, IZoneFactory factory) - : IPluginBehavior { +public class RandomZoneGenerator(IZoneManager zoneManager, IZoneFactory factory, + IServiceProvider provider) : IPluginBehavior { private IZone? cells; private string? currentMap; private IList? manualSpawnPoints; @@ -44,13 +46,17 @@ private void reload() { private void tick() { if (currentMap != Server.MapName) reload(); currentMap = Server.MapName; + + var sdManager = provider.GetService(); + if (sdManager is { IsSDRunning: true }) return; + foreach (var player in PlayerUtil.GetAlive()) tick(player); } private void tick(CCSPlayerController player) { var pawn = player.PlayerPawn.Value; if (pawn == null) return; - if (!pawn.OnGroundLastTick) return; + if (!pawn.OnGroundLastTick || !pawn.TakesDamage) return; var pos = pawn.AbsOrigin; if (pos == null) return; pos = pos.Clone();