Skip to content

Commit d4a6505

Browse files
committed
Update v1.2.8
1 parent db8e8b8 commit d4a6505

File tree

8 files changed

+341
-26
lines changed

8 files changed

+341
-26
lines changed

source/Deathmatch/API.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public void SetupCustomSpawns(List<SpawnData> spawns, bool clearSpawnsDictionary
104104
}
105105

106106
spawnPoints = spawns;
107+
foreach (var data in spawnPoints)
108+
{
109+
if (data.Entity != null && data.Entity.IsValid)
110+
continue;
111+
data.Entity = CreateSpawnEntity(data.Position, data.Angle, data.Team);
112+
}
107113
RemoveUnusedSpawns();
108114
}
109115

source/Deathmatch/Common/Collections.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public partial class Deathmatch
1010
//public static Dictionary<Vector, QAngle> spawnPositionsCT = new();
1111
//public static Dictionary<Vector, QAngle> spawnPositionsT = new();
1212
public static List<SpawnData> spawnPoints = new();
13-
1413
public static Dictionary<int, Vector> blockedSpawns = new();
1514
public static Dictionary<int, DeathmatchPlayerData> playerData = new();
1615
public Dictionary<CCSPlayerController, (float timer, float currentTime)> playersWaitingForRespawn = new();

source/Deathmatch/Deathmatch.cs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,19 @@ public override void Load(bool hotReload)
6262
playerData.Clear();
6363
playersWaitingForRespawn.Clear();
6464
playersWithSpawnProtection.Clear();
65+
6566
if (!mapLoaded)
6667
{
6768
mapLoaded = true;
6869
bool RoundTerminated = false;
6970
DefaultMapSpawnDisabled = false;
70-
AddTimer(3.0f, () =>
71+
AddTimer(0.2f, () =>
7172
{
7273
LoadCustomConfigFile();
74+
});
75+
76+
AddTimer(3.0f, () =>
77+
{
7378
SetupCustomMode(Config.Gameplay.MapStartMode.ToString());
7479
SetupDeathMatchConfigValues();
7580
RemoveEntities();
@@ -123,12 +128,42 @@ public override void Load(bool hotReload)
123128
if (secTimer >= 1)
124129
{
125130
secTimer = 0;
131+
if (VisibleHud)
132+
{
133+
foreach (var p in Utilities.GetPlayers())
134+
{
135+
if (!playerData.TryGetValue(p.Slot, out var data))
136+
continue;
137+
138+
if ((Config.PlayersPreferences.HudMessages.Enabled && !GetPrefsValue(data, "HudMessages", Config.PlayersPreferences.HudMessages.DefaultValue)) || MenuManager.GetActiveMenu(p) != null)
139+
continue;
140+
141+
if (RemainingTime <= Config.Gameplay.NewModeCountdown && Config.Gameplay.NewModeCountdown > 0)
142+
{
143+
if (RemainingTime == 0)
144+
{
145+
if (Config.Gameplay.HudType == 0)
146+
p.PrintToCenter($"{Localizer["Hud.NewModeStarted"]}");
147+
}
148+
else if (!Config.General.HideModeRemainingTime && Config.CustomModes.TryGetValue(NextMode.ToString(), out var NextModeData))
149+
{
150+
if (Config.Gameplay.HudType == 1)
151+
p.PrintToCenter($"{Localizer["Hud.NewModeStarting", RemainingTime, NextModeData.Name]}");
152+
}
153+
}
154+
else if (!string.IsNullOrEmpty(ActiveMode.CenterMessageText))
155+
{
156+
if (Config.Gameplay.HudType == 0)
157+
p.PrintToCenter(ModeCenterMessage);
158+
}
159+
}
160+
}
161+
126162
if (GameRules == null)
127163
{
128164
SetGameRules();
129-
return;
130165
}
131-
if (!GameRules.WarmupPeriod)
166+
else if (!GameRules.WarmupPeriod)
132167
{
133168
ModeTimer++;
134169
RemainingTime = ActiveMode.Interval - ModeTimer;
@@ -186,10 +221,8 @@ public override void Load(bool hotReload)
186221
}
187222
else if (!Config.General.HideModeRemainingTime && Config.CustomModes.TryGetValue(NextMode.ToString(), out var NextModeData))
188223
{
189-
if (Config.Gameplay.HudType == 1)
190-
p.PrintToCenter($"{Localizer["Hud.NewModeStarting", RemainingTime, NextModeData.Name]}");
191-
//else
192-
// p.PrintToCenterHtml($"{Localizer["Hud.NewModeStarting", RemainingTime, NextModeData.Name]}");
224+
if (Config.Gameplay.HudType == 0)
225+
p.PrintToCenterHtml($"{Localizer["Hud.NewModeStarting", RemainingTime, NextModeData.Name]}");
193226
}
194227
}
195228
else if (!string.IsNullOrEmpty(ActiveMode.CenterMessageText))

source/Deathmatch/Events.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public partial class Deathmatch
1515
[GameEventHandler(HookMode.Post)]
1616
public HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
1717
{
18+
//var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_counterterrorist").Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_terrorist")).Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_deathmatch_spawn"));
19+
//SendConsoleMessage($"spawns entities: {spawns.Count()}", ConsoleColor.DarkCyan);
1820
var player = @event.Userid;
1921
if (player != null && player.IsValid && !player.IsBot && !player.IsHLTV && player.SteamID.ToString().Length == 17 && !playerData.ContainsKey(player.Slot))
2022
{

source/Deathmatch/Functions/Commands.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ public void OnEditor_CMD(CCSPlayerController player, CommandInfo info)
167167
OpenEditorMenu(player);
168168
}
169169

170-
/*[ConsoleCommand("css_test", "")]
170+
[ConsoleCommand("css_test", "")]
171171
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
172172
public void test_CMD(CCSPlayerController player, CommandInfo info)
173173
{
174-
var targetString = info.GetArg(1);
174+
player.PrintToCenter("čus");
175+
/*var targetString = info.GetArg(1);
175176
var target = Utilities.GetPlayers().FirstOrDefault(p => p.PlayerName.Contains(targetString));
176177
if (target == null)
177178
{
@@ -180,7 +181,7 @@ public void test_CMD(CCSPlayerController player, CommandInfo info)
180181
}
181182
182183
var result = CanSeeSpawn(player.PlayerPawn.Value, target.PlayerPawn.Value.AbsOrigin);
183-
info.ReplyToCommand($"result {target.PlayerName}: {result}");
184-
}*/
184+
info.ReplyToCommand($"result {target.PlayerName}: {result}");*/
185+
}
185186
}
186187
}

source/Deathmatch/Functions/Menus.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@ public void OpenEditorMenu(CCSPlayerController? player)
3636
{
3737
AddNewSpawnPoint(player.PlayerPawn.Value?.AbsOrigin!, player.PlayerPawn.Value?.AbsRotation!, CsTeam.CounterTerrorist);
3838
player.PrintToChat($"{Localizer["Chat.Prefix"]} Spawn for the {ChatColors.DarkBlue}CT team{ChatColors.Default} has been added. (Total: {ChatColors.Green}{spawnPoints.Count(x => x.Team == CsTeam.CounterTerrorist)}{ChatColors.Default})");
39+
RemoveUnusedSpawns();
3940
OpenEditorMenu(player);
4041
});
4142
Menu.AddMenuOption($"Add T Spawn ({tSpawns})", (player, opt) =>
4243
{
4344
AddNewSpawnPoint(player.PlayerPawn.Value?.AbsOrigin!, player.PlayerPawn.Value?.AbsRotation!, CsTeam.Terrorist);
4445
player.PrintToChat($"{Localizer["Chat.Prefix"]} Spawn for the {ChatColors.Orange}T team{ChatColors.Default} has been added. (Total: {ChatColors.Green}{spawnPoints.Count(x => x.Team == CsTeam.Terrorist)}{ChatColors.Default})");
46+
RemoveUnusedSpawns();
4547
OpenEditorMenu(player);
4648
});
4749

4850
Menu.AddMenuOption("Remove the Nearest Spawn", (player, opt) =>
4951
{
5052
RemoveNearestSpawnPoint(player.PlayerPawn.Value!.AbsOrigin);
5153
player.PrintToChat($"{Localizer["Chat.Prefix"]} The nearest spawn point has been removed!");
54+
RemoveUnusedSpawns();
5255
OpenEditorMenu(player);
5356
});
5457

source/Deathmatch/Functions/Spawns.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,27 @@ public void ShowAllSpawnPoints()
227227
}
228228
}
229229

230-
public static void RemoveUnusedSpawns()
230+
public static void RemoveUnusedSpawns(bool defaultSpawns = false)
231231
{
232-
if (!DefaultMapSpawnDisabled)
232+
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_counterterrorist").Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_terrorist")).Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_deathmatch_spawn"));
233+
int DMSpawns = 0;
234+
foreach (var entity in spawns)
233235
{
234-
var spawns = Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_counterterrorist").Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_player_terrorist")).Concat(Utilities.FindAllEntitiesByDesignerName<SpawnPoint>("info_deathmatch_spawn"));
235-
int DMSpawns = 0;
236-
foreach (var entity in spawns)
237-
{
238-
if (entity == null || !entity.IsValid)
239-
continue;
240-
241-
if (spawnPoints.Any(x => x.Entity == entity))
242-
continue;
236+
if (entity == null || !entity.IsValid)
237+
continue;
243238

244-
entity.AcceptInput("Kill");
239+
if (spawnPoints.Any(x => x.Entity == entity))
240+
entity.AcceptInput("SetEnabled");
241+
else
242+
{
243+
entity.AcceptInput("SetDisabled");
245244
DMSpawns++;
246245
}
247-
SendConsoleMessage($"[Deathmatch] Total {DMSpawns} Spawns disabled!", ConsoleColor.Green);
246+
}
247+
248+
if (defaultSpawns)
249+
{
250+
SendConsoleMessage($"[Deathmatch] Total {DMSpawns} Default Spawns disabled!", ConsoleColor.Green);
248251
DefaultMapSpawnDisabled = true;
249252
}
250253
}
@@ -336,7 +339,7 @@ public void LoadMapSpawns(string filePath)
336339
}
337340

338341
SendConsoleMessage($"[Deathmatch] Total Loaded Custom Spawns: CT {spawnPoints.Count(x => x.Team == CsTeam.CounterTerrorist)} | T {spawnPoints.Count(x => x.Team == CsTeam.Terrorist)}", ConsoleColor.Green);
339-
RemoveUnusedSpawns();
342+
RemoveUnusedSpawns(true);
340343
}
341344
}
342345

0 commit comments

Comments
 (0)