11using CounterStrikeSharp . API ;
22using CounterStrikeSharp . API . Core ;
33using CounterStrikeSharp . API . Modules . Utils ;
4- using CSSharpUtils . Utils ;
5- using FixVectorLeak . src . Structs ;
64using AntiRush . Extensions ;
5+ using CSSharpUtils . Utils ;
76using FixVectorLeak . src ;
7+ using FixVectorLeak . src . Structs ;
88
99namespace AntiRush ;
1010
@@ -16,7 +16,7 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
1616 _gameRules = GameUtils . GetGameRules ( ) ;
1717 _roundStart = Server . CurrentTime ;
1818
19- var count = Utilities . GetPlayers ( ) . Where ( p => p . Team is CsTeam . CounterTerrorist or CsTeam . Terrorist ) . ToList ( ) . Count ;
19+ var count = Utilities . GetPlayers ( ) . Where ( p => p . Team is ( CsTeam . CounterTerrorist or CsTeam . Terrorist ) ) . ToList ( ) . Count ;
2020 _minPlayers = count >= Config . MinPlayers ;
2121 _maxPlayers = count < Config . MaxPlayers ;
2222
@@ -33,7 +33,7 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
3333
3434 private HookResult OnBombPlanted ( EventBombPlanted @event , GameEventInfo info )
3535 {
36- if ( ! Config . DisableOnBombPlant || ! _minPlayers )
36+ if ( ! Config . DisableOnBombPlant || ! _minPlayers || ! _maxPlayers )
3737 return HookResult . Continue ;
3838
3939 _bombPlanted = true ;
@@ -46,7 +46,7 @@ private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
4646 {
4747 var player = @event . Userid ;
4848
49- if ( player == null || ! player . IsValid ( ) || player . PlayerPawn . Value == null || player . PlayerPawn . Value . AbsOrigin == null )
49+ if ( player == null || ! player . IsValid ( ) || player . PlayerPawn . Value ? . AbsOrigin == null )
5050 return HookResult . Continue ;
5151
5252 var origin = player . PlayerPawn . Value . AbsOrigin . ToVector_t ( ) ;
@@ -64,7 +64,7 @@ private HookResult OnBulletImpact(EventBulletImpact @event, GameEventInfo info)
6464 if ( player == null || ! player . IsValid ( ) || ! _playerData . TryGetValue ( player , out var playerData ) || playerData . AddZoneMenu == null || ! Menu . IsCurrentMenu ( player , playerData . AddZoneMenu ) )
6565 return HookResult . Continue ;
6666
67- if ( playerData . AddZoneMenu is null || playerData . AddZoneMenu . Points [ 0 ] is not null && playerData . AddZoneMenu . Points [ 1 ] is not null )
67+ if ( playerData . AddZoneMenu . Points [ 0 ] is not null && playerData . AddZoneMenu . Points [ 1 ] is not null )
6868 return HookResult . Continue ;
6969
7070 if ( Server . CurrentTime - playerData . AddZoneMenu . LastShot < 0.1 )
@@ -100,12 +100,14 @@ private HookResult OnBulletImpact(EventBulletImpact @event, GameEventInfo info)
100100 if ( diffZ < 200 )
101101 {
102102 if ( playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z >= playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z )
103- playerData . AddZoneMenu . Points [ 0 ] = new Vector_t ( playerData . AddZoneMenu . Points [ 0 ] ! . Value . X , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z + ( ( playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z >= playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z ? 1 : - 1 ) * ( ( 200 - diffZ ) / 2 ) ) ) ;
103+ playerData . AddZoneMenu . Points [ 0 ] = new Vector_t ( playerData . AddZoneMenu . Points [ 0 ] ! . Value . X , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z + 200 - diffZ ) ;
104104 else
105- playerData . AddZoneMenu . Points [ 1 ] = new Vector_t ( playerData . AddZoneMenu . Points [ 1 ] ! . Value . X , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z + ( ( playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z > playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z ? - 1 : 1 ) * ( ( 200 - diffZ ) / 2 ) ) ) ;
105+ playerData . AddZoneMenu . Points [ 1 ] = new Vector_t ( playerData . AddZoneMenu . Points [ 1 ] ! . Value . X , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z + 200 - diffZ ) ;
106106 }
107107
108- playerData . AddZone = new Zone ( [ playerData . AddZoneMenu . Points [ 0 ] ! . Value . X , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z ] , [ playerData . AddZoneMenu . Points [ 1 ] ! . Value . X , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z ] ) ;
108+ playerData . AddZone ??= new Zone ( [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] ) ;
109+ playerData . AddZone . MinPoint = [ playerData . AddZoneMenu . Points [ 0 ] ! . Value . X , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 0 ] ! . Value . Z ] ;
110+ playerData . AddZone . MaxPoint = [ playerData . AddZoneMenu . Points [ 1 ] ! . Value . X , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Y , playerData . AddZoneMenu . Points [ 1 ] ! . Value . Z ] ;
109111 playerData . AddZone . Draw ( ) ;
110112 }
111113
0 commit comments