1- using Microsoft . Extensions . Logging ;
2- using System . Runtime . InteropServices ;
1+ using AntiRush . Classes ;
2+ using AntiRush . Enums ;
3+ using AntiRush . Extensions ;
34using CounterStrikeSharp . API ;
45using CounterStrikeSharp . API . Core ;
56using CounterStrikeSharp . API . Modules . Utils ;
6- using AntiRush . Classes ;
7- using AntiRush . Enums ;
8- using AntiRush . Extensions ;
97using CSSharpUtils . Extensions ;
108using CSSharpUtils . Utils ;
11- using FixVectorLeak . src ;
12- using FixVectorLeak . src . Structs ;
9+ using FixVectorLeak . Extensions ;
10+ using FixVectorLeak . Structs ;
11+ using Microsoft . Extensions . Logging ;
1312
1413namespace AntiRush ;
1514
@@ -49,24 +48,22 @@ public override void Load(bool isReload)
4948 Server . ExecuteCommand ( "mp_restartgame 1" ) ;
5049 } ) ;
5150
52- _isLinux = RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) ;
53-
5451 Logger . LogInformation ( "{ModuleName} loaded successfully!" , ModuleName ) ;
55- _ProcessMovement = new ( GameData . GetSignature ( "RunCommand" ) ) ;
56- _ProcessMovement ! . Hook ( OnProcessMovement , HookMode . Pre ) ;
5752 }
5853
5954 public override void Unload ( bool isReload )
6055 {
6156 Logger . LogInformation ( "{ModuleName} unloaded successfully!" , ModuleName ) ;
62- _ProcessMovement ! . Unhook ( OnProcessMovement , HookMode . Pre ) ;
6357 }
6458
6559 private void SaveZone ( CCSPlayerController player )
6660 {
67- var menu = _playerData [ player ] . AddZoneMenu ;
68- _playerData [ player ] . AddZone ? . Clear ( ) ;
69-
61+ if ( ! _playerData . TryGetValue ( player , out var playerData ) )
62+ return ;
63+
64+ var menu = playerData . AddZoneMenu ;
65+ playerData . AddZone ? . Clear ( ) ;
66+
7067 CsTeam [ ] teams = menu ! . Items [ 1 ] . Option switch
7168 {
7269 0 => [ CsTeam . Terrorist , CsTeam . CounterTerrorist ] ,
@@ -76,8 +73,8 @@ private void SaveZone(CCSPlayerController player)
7673 } ;
7774
7875 var zoneType = ( ZoneType ) menu . Items [ 0 ] . Option ;
79- float [ ] minPoint = [ Math . Min ( menu . Points [ 0 ] ! . Value . X , menu . Points [ 1 ] ! . Value . X ) , Math . Min ( menu . Points [ 0 ] ! . Value . Y , menu . Points [ 1 ] ! . Value . Y ) , Math . Min ( menu . Points [ 0 ] ! . Value . Z , menu . Points [ 1 ] ! . Value . Z ) ] ;
80- float [ ] maxPoint = [ Math . Max ( menu . Points [ 0 ] ! . Value . X , menu . Points [ 1 ] ! . Value . X ) , Math . Max ( menu . Points [ 0 ] ! . Value . Y , menu . Points [ 1 ] ! . Value . Y ) , Math . Max ( menu . Points [ 0 ] ! . Value . Z , menu . Points [ 1 ] ! . Value . Z ) ] ;
76+ var minPoint = new Vector_t ( Math . Min ( menu . Points [ 0 ] ! . Value . X , menu . Points [ 1 ] ! . Value . X ) , Math . Min ( menu . Points [ 0 ] ! . Value . Y , menu . Points [ 1 ] ! . Value . Y ) , Math . Min ( menu . Points [ 0 ] ! . Value . Z , menu . Points [ 1 ] ! . Value . Z ) ) ;
77+ var maxPoint = new Vector_t ( Math . Max ( menu . Points [ 0 ] ! . Value . X , menu . Points [ 1 ] ! . Value . X ) , Math . Max ( menu . Points [ 0 ] ! . Value . Y , menu . Points [ 1 ] ! . Value . Y ) , Math . Max ( menu . Points [ 0 ] ! . Value . Z , menu . Points [ 1 ] ! . Value . Z ) ) ;
8178 var delay = zoneType != ZoneType . Bounce && float . TryParse ( menu . Items [ 3 ] . DataString , out var valueDelay ) ? ( float ) Math . Floor ( valueDelay * 10 ) / 10 : 0 ;
8279 var damage = zoneType == ZoneType . Hurt && int . TryParse ( menu . Items [ 4 ] . DataString , out var valueDamage ) ? valueDamage : 0 ;
8380 var name = menu . Items [ 2 ] . DataString ;
@@ -106,9 +103,6 @@ private void SaveZone(CCSPlayerController player)
106103
107104 if ( Config . DrawZones )
108105 zone . Draw ( ) ;
109-
110- if ( _playerData . TryGetValue ( player , out var playerData ) )
111- playerData . AddZone ? . Clear ( ) ;
112106 }
113107
114108 private bool PrintAction ( CCSPlayerController player , Zone zone )
@@ -153,16 +147,17 @@ private void DoAction(CCSPlayerController player, Zone zone)
153147 if ( player . PlayerPawn . Value ? . MovementServices is null )
154148 return ;
155149
156- if ( PrintAction ( player , zone ) )
157- _playerData [ player ] . LastMessage = Server . CurrentTime ;
150+ if ( ! _playerData . TryGetValue ( player , out var playerData ) )
151+ return ;
158152
159- if ( zone . Type is ( ZoneType . Bounce or ZoneType . Wall ) )
160- _playerData [ player ] . BlockButtons = Server . TickedTime + 0.3 ;
153+ if ( PrintAction ( player , zone ) )
154+ playerData . LastMessage = Server . CurrentTime ;
161155
162156 switch ( zone . Type )
163157 {
164158 case ZoneType . Bounce :
165- player . Bounce ( _playerData [ player ] . LastPos , _playerData [ player ] . LastVel ) ;
159+ if ( playerData . LastPos is not null && playerData . LastVel is not null )
160+ player . Bounce ( ( Vector_t ) playerData . LastPos , ( Vector_t ) playerData . LastVel ) ;
166161
167162 return ;
168163
@@ -177,13 +172,15 @@ private void DoAction(CCSPlayerController player, Zone zone)
177172 return ;
178173
179174 case ZoneType . Teleport :
180- if ( _playerData [ player ] . SpawnPos is not null )
181- player . PlayerPawn . Value . Teleport ( _playerData [ player ] . SpawnPos , velocity : new Vector_t ( ) ) ;
175+ if ( playerData . SpawnPos is not null )
176+ player . PlayerPawn . Value . Teleport ( playerData . SpawnPos , velocity : new Vector_t ( ) ) ;
182177
183178 return ;
184179
185180 case ZoneType . Wall :
186- player . PlayerPawn . Value . Teleport ( new Vector_t ( _playerData [ player ] . LastPos [ 0 ] , _playerData [ player ] . LastPos [ 1 ] , _playerData [ player ] . LastPos [ 2 ] ) , velocity : new Vector_t ( ) ) ;
181+ if ( playerData . LastPos is not null )
182+ player . PlayerPawn . Value . Teleport ( playerData . LastPos , velocity : new Vector_t ( ) ) ;
183+
187184 return ;
188185 }
189186 }
0 commit comments