@@ -103,7 +103,7 @@ public void PerformRespawn(CCSPlayerController player, CsTeam team)
103103 }
104104
105105 SendConsoleMessage ( $ "[Deathmatch] Player { player . PlayerName } was respawned, but no available spawn point was found!", ConsoleColor . DarkYellow ) ;
106- return null ;
106+ return spawnsList . FirstOrDefault ( ) ;
107107 }
108108
109109 public void SaveSpawnsFile ( )
@@ -138,7 +138,6 @@ public void AddNewSpawnPoint(Vector posValue, QAngle angleValue, CsTeam team)
138138 {
139139 if ( ! DefaultMapSpawnDisabled )
140140 {
141- DefaultMapSpawnDisabled = true ;
142141 spawnPoints . Clear ( ) ;
143142 }
144143
@@ -227,29 +226,24 @@ public void ShowAllSpawnPoints()
227226 }
228227 }
229228
230- public static void RemoveUnusedSpawns ( bool defaultSpawns = false )
229+ public static void DisableDefaultSpawns ( )
231230 {
231+ if ( DefaultMapSpawnDisabled )
232+ return ;
233+
232234 var spawns = Utilities . FindAllEntitiesByDesignerName < SpawnPoint > ( "info_player_counterterrorist" ) . Concat ( Utilities . FindAllEntitiesByDesignerName < SpawnPoint > ( "info_player_terrorist" ) ) . Concat ( Utilities . FindAllEntitiesByDesignerName < SpawnPoint > ( "info_deathmatch_spawn" ) ) ;
233235 int DMSpawns = 0 ;
234236 foreach ( var entity in spawns )
235237 {
236238 if ( entity == null || ! entity . IsValid )
237239 continue ;
238240
239- if ( spawnPoints . Any ( x => x . Entity == entity ) )
240- entity . AcceptInput ( "SetEnabled" ) ;
241- else
242- {
243- entity . AcceptInput ( "SetDisabled" ) ;
244- DMSpawns ++ ;
245- }
241+ entity . AcceptInput ( "SetDisabled" ) ;
242+ DMSpawns ++ ;
246243 }
247244
248- if ( defaultSpawns )
249- {
250- SendConsoleMessage ( $ "[Deathmatch] Total { DMSpawns } Default Spawns disabled!", ConsoleColor . Green ) ;
251- DefaultMapSpawnDisabled = true ;
252- }
245+ SendConsoleMessage ( $ "[Deathmatch] Total { DMSpawns } Default Spawns disabled!", ConsoleColor . Green ) ;
246+ DefaultMapSpawnDisabled = true ;
253247 }
254248
255249 /*public static void CreateCustomMapSpawns()
@@ -284,7 +278,7 @@ public static void RemoveUnusedSpawns(bool defaultSpawns = false)
284278 }
285279 }*/
286280
287- public SpawnPoint ? CreateSpawnEntity ( Vector Postion , QAngle Angle , CsTeam team )
281+ public void CreateSpawnEntity ( Vector Postion , QAngle Angle , CsTeam team )
288282 {
289283 var entityName = "info_deathmatch_spawn" ;
290284 if ( IsCasualGamemode )
@@ -294,11 +288,10 @@ public static void RemoveUnusedSpawns(bool defaultSpawns = false)
294288 if ( entity == null )
295289 {
296290 SendConsoleMessage ( $ "[Deathmatch] Failed to create spawn point!", ConsoleColor . DarkYellow ) ;
297- return null ;
291+ return ;
298292 }
299293 entity . Teleport ( Postion , Angle , new Vector ( 0 , 0 , 0 ) ) ;
300294 entity . DispatchSpawn ( ) ;
301- return entity ;
302295 }
303296
304297 public void LoadMapSpawns ( string filePath )
@@ -317,6 +310,7 @@ public void LoadMapSpawns(string filePath)
317310 }
318311 else
319312 {
313+ DisableDefaultSpawns ( ) ;
320314 SendConsoleMessage ( $ "[Deathmatch] Loading Custom Map Spawns..", ConsoleColor . DarkYellow ) ;
321315
322316 var jsonContent = File . ReadAllText ( filePath ) ;
@@ -333,13 +327,13 @@ public void LoadMapSpawns(string filePath)
333327 Team = team ,
334328 Position = pos ,
335329 Angle = angle ,
336- Entity = CreateSpawnEntity ( pos , angle , team )
337330 } ;
331+
338332 spawnPoints . Add ( spawn ) ;
333+ CreateSpawnEntity ( pos , angle , team ) ;
339334 }
340335
341336 SendConsoleMessage ( $ "[Deathmatch] Total Loaded Custom Spawns: CT { spawnPoints . Count ( x => x . Team == CsTeam . CounterTerrorist ) } | T { spawnPoints . Count ( x => x . Team == CsTeam . Terrorist ) } ", ConsoleColor . Green ) ;
342- RemoveUnusedSpawns ( true ) ;
343337 }
344338 }
345339
@@ -403,8 +397,7 @@ public void addDefaultSpawnsToList()
403397 {
404398 Position = spawn . AbsOrigin ,
405399 Angle = spawn . AbsRotation ,
406- Team = CsTeam . CounterTerrorist ,
407- Entity = spawn
400+ Team = CsTeam . CounterTerrorist
408401 } ;
409402 spawnPoints . Add ( data ) ;
410403 }
@@ -417,8 +410,7 @@ public void addDefaultSpawnsToList()
417410 {
418411 Position = spawn . AbsOrigin ,
419412 Angle = spawn . AbsRotation ,
420- Team = CsTeam . Terrorist ,
421- Entity = spawn
413+ Team = CsTeam . Terrorist
422414 } ;
423415 spawnPoints . Add ( data ) ;
424416 }
@@ -438,8 +430,7 @@ public void addDefaultSpawnsToList()
438430 {
439431 Position = spawn . AbsOrigin ,
440432 Angle = spawn . AbsRotation ,
441- Team = CsTeam . Terrorist ,
442- Entity = spawn
433+ Team = CsTeam . Terrorist
443434 } ;
444435 spawnPoints . Add ( data ) ;
445436 }
@@ -451,8 +442,7 @@ public void addDefaultSpawnsToList()
451442 {
452443 Position = spawn . AbsOrigin ,
453444 Angle = spawn . AbsRotation ,
454- Team = CsTeam . CounterTerrorist ,
455- Entity = spawn
445+ Team = CsTeam . CounterTerrorist
456446 } ;
457447 spawnPoints . Add ( data ) ;
458448 }
0 commit comments