-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbash-adjusted.sp
3397 lines (2885 loc) · 104 KB
/
bash-adjusted.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Removed null checks and logs (kept standard deviation, see RecordKeySwitches), autokick on joystick 1, optimized queries
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <sdkhooks>
#undef REQUIRE_EXTENSIONS
#include <dhooks>
#pragma newdecls required
// ----------------------------------------------------------------------------
// Configuration
// ----------------------------------------------------------------------------
#define BAN_LENGTH "0" // Default ban length for automated bans
#define IDENTICAL_STRAFE_MIN 20 // Minimum number of identical strafes to trigger a detection
// ----------------------------------------------------------------------------
// Button and Movement Definitions
// ----------------------------------------------------------------------------
#define Button_Forward 0
#define Button_Back 1
#define Button_Left 2
#define Button_Right 3
#define BT_Move 0 // Button type: Movement keys (W, A, S, D)
#define BT_Key 1 // Button type: Other keys (Left, Right)
#define Moving_Forward 0
#define Moving_Back 1
#define Moving_Left 2
#define Moving_Right 3
#define Turn_Left 0
#define Turn_Right 1
// ----------------------------------------------------------------------------
// Strafe and Key Switch Data Indices
// ----------------------------------------------------------------------------
// Start/End Strafe Data
#define StrafeData_Button 0
#define StrafeData_TurnDirection 1
#define StrafeData_MoveDirection 2
#define StrafeData_Difference 3
#define StrafeData_Tick 4
#define StrafeData_IsTiming 5
// Key switch data
#define KeySwitchData_Button 0
#define KeySwitchData_Difference 1
#define KeySwitchData_IsTiming 2
// ----------------------------------------------------------------------------
// Detection Reasons
// ----------------------------------------------------------------------------
// Each detection reason is represented by a bit in a bit flag.
// This allows for multiple detection reasons to be flagged simultaneously.
#define DR_StartStrafe_LowDeviation (1 << 0) // < 1.0 very likely strafe hacks (Warn admins)
#define DR_StartStrafe_AlwaysPositive (1 << 1) // Might not be strafe hacking but a good indicator of someone trying to bypass anticheat (Warn admins)
#define DR_EndStrafe_LowDeviation (1 << 2) // < 1.0 very likely strafe hacks (Warn admins)
#define DR_EndStrafe_AlwaysPositive (1 << 3) // Might not be strafe hacking but a good indicator of someone trying to bypass anticheat (Warn admins)
#define DR_StartStrafeMatchesEndStrafe (1 << 4) // A way to catch an angle delay hack (Do nothing)
#define DR_KeySwitchesTooPerfect (1 << 5) // Could be movement config or anti ghosting keyboard (Warn admins)
#define DR_FailedManualAngleTest (1 << 6) // Almost definitely strafe hacking (Ban)
#define DR_ButtonsAndSideMoveDontMatch (1 << 7) // Could be caused by lag but can be made to detect strafe hacks perfectly (Ban/Warn based on severity)
#define DR_ImpossibleSideMove (1 << 8) // Could be +strafe or controller but most likely strafe hack (Warn admins/Stop player movements)
#define DR_FailedManualMOTDTest (1 << 9) // Almost definitely strafe hacking (Ban)
#define DR_AngleDelay (1 << 10) // Player freezes their angles for 1 or more ticks after they press a button until the angle changes again
#define DR_ImpossibleGains (1 << 11) // < 85% probably strafe hacks
#define DR_WiggleHack (1 << 12) // Almost definitely strafe hack. Check for IN_LEFT/IN_RIGHT
#define DR_TurningInfraction (1 << 13) // Client turns at impossible speeds
// ----------------------------------------------------------------------------
// Global Variables
// ----------------------------------------------------------------------------
// Engine version
EngineVersion g_Engine;
// Player data arrays
// These arrays store various data about each player, such as button presses,
// movement vectors, angles, and strafe statistics.
int g_iRealButtons[MAXPLAYERS + 1]; // Actual buttons pressed by the player
int g_iButtons[MAXPLAYERS + 1][2]; // Processed buttons (movement and keys)
int g_iLastButtons[MAXPLAYERS + 1][2]; // Buttons pressed in the previous tick
int g_iLastPressTick[MAXPLAYERS + 1][4][2]; // Tick number of the last button press for each button type
int g_iLastPressTick_Recorded[MAXPLAYERS + 1][4][2]; // Recorded tick number of the last button press for strafe analysis
int g_iLastPressTick_Recorded_KS[MAXPLAYERS + 1][4][2]; // Recorded tick number of the last button press for key switch analysis
int g_iKeyPressesThisStrafe[MAXPLAYERS + 1][2]; // Number of key presses during the current strafe
int g_iLastReleaseTick[MAXPLAYERS + 1][4][2]; // Tick number of the last button release for each button type
int g_iLastReleaseTick_Recorded[MAXPLAYERS + 1][4][2]; // Recorded tick number of the last button release for strafe analysis
int g_iLastReleaseTick_Recorded_KS[MAXPLAYERS + 1][4][2]; // Recorded tick number of the last button release for key switch analysis
float g_fLastMove[MAXPLAYERS + 1][3]; // Player's velocity vector in the previous tick
int g_iLastTurnDir[MAXPLAYERS + 1]; // Direction of the last turn (left or right)
int g_iLastTurnTick[MAXPLAYERS + 1]; // Tick number of the last turn
int g_iLastTurnTick_Recorded_StartStrafe[MAXPLAYERS + 1]; // Recorded tick number of the last turn for start strafe analysis
int g_iLastTurnTick_Recorded_EndStrafe[MAXPLAYERS + 1]; // Recorded tick number of the last turn for end strafe analysis
int g_iLastStopTurnTick[MAXPLAYERS + 1]; // Tick number when the player stopped turning
bool g_bIsTurning[MAXPLAYERS + 1]; // Whether the player is currently turning
int g_iReleaseTickAtLastEndStrafe[MAXPLAYERS + 1][4]; // Tick number of the last button release at the end of a strafe
float g_fLastAngles[MAXPLAYERS + 1][3]; // Player's view angles in the previous tick
int g_InvalidButtonSidemoveCount[MAXPLAYERS + 1]; // Number of consecutive ticks with invalid button and sidemove combinations
int g_iCmdNum[MAXPLAYERS + 1]; // Number of commands received from the player
float g_fLastPosition[MAXPLAYERS + 1][3]; // Player's position in the previous tick
int g_iLastTeleportTick[MAXPLAYERS + 1]; // Tick number of the last teleport
float g_fAngleDifference[MAXPLAYERS + 1][2]; // Difference between current and previous view angles
float g_fLastAngleDifference[MAXPLAYERS + 1][2]; // Angle difference in the previous tick
// Gain calculation variables
// These variables are used to calculate the player's gain percentage,
// which is a measure of how much speed they are gaining from strafing.
int g_strafeTick[MAXPLAYERS + 1]; // Number of ticks since the start of the current strafe
float g_flRawGain[MAXPLAYERS + 1]; // Accumulated gain value
bool g_bTouchesWall[MAXPLAYERS + 1]; // Whether the player is currently touching a wall
int g_iJump[MAXPLAYERS + 1]; // Number of consecutive jumps
int g_iTicksOnGround[MAXPLAYERS + 1]; // Number of consecutive ticks the player has been on the ground
float g_iYawSpeed[MAXPLAYERS + 1]; // Player's yaw speed (from cl_yawspeed)
int g_iYawTickCount[MAXPLAYERS + 1]; // Number of ticks the player has been yawing
int g_iTimingTickCount[MAXPLAYERS + 1]; // Number of ticks the player has been timing their strafes
int g_iStrafesDone[MAXPLAYERS + 1]; // Number of strafes performed
bool g_bFirstSixJumps[MAXPLAYERS + 1]; // Whether the player is in their first six jumps
#define BHOP_TIME 15 // Number of ticks on ground before resetting jump count
// Optimizer detection variable
bool g_bTouchesFuncRotating[MAXPLAYERS + 1]; // Whether the player is touching a func_rotating entity
// Mouse cvars
// These variables store the values of various mouse-related convars,
// which are used to detect illegal turning rates.
// Mouse cvars
float g_mYaw[MAXPLAYERS + 1]; int g_mYawChangedCount[MAXPLAYERS + 1]; int g_mYawCheckedCount[MAXPLAYERS + 1];
bool g_mFilter[MAXPLAYERS + 1]; int g_mFilterChangedCount[MAXPLAYERS + 1]; int g_mFilterCheckedCount[MAXPLAYERS + 1];
int g_mCustomAccel[MAXPLAYERS + 1]; int g_mCustomAccelChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelCheckedCount[MAXPLAYERS + 1];
float g_mCustomAccelMax[MAXPLAYERS + 1]; int g_mCustomAccelMaxChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelMaxCheckedCount[MAXPLAYERS + 1];
float g_mCustomAccelScale[MAXPLAYERS + 1]; int g_mCustomAccelScaleChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelScaleCheckedCount[MAXPLAYERS + 1];
float g_mCustomAccelExponent[MAXPLAYERS + 1]; int g_mCustomAccelExponentChangedCount[MAXPLAYERS + 1]; int g_mCustomAccelExponentCheckedCount[MAXPLAYERS + 1];
bool g_mRawInput[MAXPLAYERS + 1]; int g_mRawInputChangedCount[MAXPLAYERS + 1]; int g_mRawInputCheckedCount[MAXPLAYERS + 1];
float g_Sensitivity[MAXPLAYERS + 1]; int g_SensitivityChangedCount[MAXPLAYERS + 1]; int g_SensitivityCheckedCount[MAXPLAYERS + 1];
// float g_JoySensitivity[MAXPLAYERS + 1]; int g_JoySensitivityChangedCount[MAXPLAYERS + 1]; int g_JoySensitivityCheckedCount[MAXPLAYERS + 1];
float g_ZoomSensitivity[MAXPLAYERS + 1]; int g_ZoomSensitivityChangedCount[MAXPLAYERS + 1]; int g_ZoomSensitivityCheckedCount[MAXPLAYERS + 1];
bool g_JoyStick[MAXPLAYERS + 1]; int g_JoyStickChangedCount[MAXPLAYERS + 1]; int g_JoyStickCheckedCount[MAXPLAYERS + 1];
// Recorded data arrays
// These arrays store historical data about strafes and key switches,
// which is used to analyze patterns and detect anomalies.
#define MAX_FRAMES 400 // Maximum number of frames to record for strafe analysis
#define MAX_FRAMES_KEYSWITCH 400 // Maximum number of frames to record for key switch analysis
int g_iStartStrafe_CurrentFrame[MAXPLAYERS + 1]; // Current frame index for start strafe recording
any g_iStartStrafe_Stats[MAXPLAYERS + 1][7][MAX_FRAMES]; // Start strafe data
int g_iStartStrafe_LastRecordedTick[MAXPLAYERS + 1]; // Tick number of the last recorded start strafe
int g_iStartStrafe_LastTickDifference[MAXPLAYERS + 1]; // Difference between the last two recorded start strafes
bool g_bStartStrafe_IsRecorded[MAXPLAYERS + 1][MAX_FRAMES]; // Whether a start strafe has been recorded for each frame
int g_iStartStrafe_IdenticalCount[MAXPLAYERS + 1]; // Number of consecutive identical start strafes
int g_iEndStrafe_CurrentFrame[MAXPLAYERS + 1]; // Current frame index for end strafe recording
any g_iEndStrafe_Stats[MAXPLAYERS + 1][7][MAX_FRAMES]; // End strafe data
int g_iEndStrafe_LastRecordedTick[MAXPLAYERS + 1]; // Tick number of the last recorded end strafe
int g_iEndStrafe_LastTickDifference[MAXPLAYERS + 1]; // Difference between the last two recorded end strafes
bool g_bEndStrafe_IsRecorded[MAXPLAYERS + 1][MAX_FRAMES]; // Whether an end strafe has been recorded for each frame
int g_iEndStrafe_IdenticalCount[MAXPLAYERS + 1]; // Number of consecutive identical end strafes
int g_iKeySwitch_CurrentFrame[MAXPLAYERS + 1][2]; // Current frame index for key switch recording for each button type
any g_iKeySwitch_Stats[MAXPLAYERS + 1][3][2][MAX_FRAMES_KEYSWITCH]; // Key switch data
bool g_bKeySwitch_IsRecorded[MAXPLAYERS + 1][2][MAX_FRAMES_KEYSWITCH]; // Whether a key switch has been recorded for each frame and button type
int g_iKeySwitch_LastRecordedTick[MAXPLAYERS + 1][2]; // Tick number of the last recorded key switch for each button type
bool g_iIllegalTurn[MAXPLAYERS + 1][MAX_FRAMES]; // Whether an illegal turn has been detected for each frame
int g_iIllegalTurn_CurrentFrame[MAXPLAYERS + 1]; // Current frame index for illegal turn recording
bool g_iIllegalTurn_IsTiming[MAXPLAYERS + 1][MAX_FRAMES]; // Whether the illegal turn was performed during a timing strafe
int g_iLastIllegalReason[MAXPLAYERS + 1]; // Reason for the last illegal movement detection
int g_iIllegalSidemoveCount[MAXPLAYERS + 1]; // Number of consecutive ticks with illegal sidemove values
int g_iLastIllegalSidemoveCount[MAXPLAYERS + 1]; // Illegal sidemove count in the previous tick
int g_iLastInvalidButtonCount[MAXPLAYERS + 1]; // Invalid button count in the previous tick
int g_iYawChangeCount[MAXPLAYERS + 1]; // Number of yaw changes during illegal sidemove
// MOTD Test
bool g_bCheckedYet[MAXPLAYERS + 1];
float g_MOTDTestAngles[MAXPLAYERS + 1][3];
bool g_bMOTDTest[MAXPLAYERS + 1];
// Persistent data
// This struct is used to store persistent data about players,
// such as strafe statistics, which can be saved and loaded between maps.
// Note: This struct is defined to reduce memory usage by flattening the multi-dimensional arrays.
// This is necessary because SourceMod has a limited amount of memory available for plugins.
enum struct fuck_sourcemod
{
int accountid; // Steam account ID
// Button and movement data
int g_iRealButtons;
int g_iButtons[2];
int g_iLastButtons[2];
int g_iLastPressTick_0[2];
int g_iLastPressTick_1[2];
int g_iLastPressTick_2[2];
int g_iLastPressTick_3[2];
int g_iLastPressTick_Recorded_0[2];
int g_iLastPressTick_Recorded_1[2];
int g_iLastPressTick_Recorded_2[2];
int g_iLastPressTick_Recorded_3[2];
int g_iLastPressTick_Recorded_KS_0[2];
int g_iLastPressTick_Recorded_KS_1[2];
int g_iLastPressTick_Recorded_KS_2[2];
int g_iLastPressTick_Recorded_KS_3[2];
int g_iKeyPressesThisStrafe[2];
int g_iLastReleaseTick_0[2];
int g_iLastReleaseTick_1[2];
int g_iLastReleaseTick_2[2];
int g_iLastReleaseTick_3[2];
int g_iLastReleaseTick_Recorded_0[2];
int g_iLastReleaseTick_Recorded_1[2];
int g_iLastReleaseTick_Recorded_2[2];
int g_iLastReleaseTick_Recorded_3[2];
int g_iLastReleaseTick_Recorded_KS_0[2];
int g_iLastReleaseTick_Recorded_KS_1[2];
int g_iLastReleaseTick_Recorded_KS_2[2];
int g_iLastReleaseTick_Recorded_KS_3[2];
float g_fLastMove[3];
int g_iLastTurnDir;
int g_iLastTurnTick;
int g_iLastTurnTick_Recorded_StartStrafe;
int g_iLastTurnTick_Recorded_EndStrafe;
int g_iLastStopTurnTick;
bool g_bIsTurning;
int g_iReleaseTickAtLastEndStrafe[4];
float g_fLastAngles[3];
int g_InvalidButtonSidemoveCount;
int g_iCmdNum;
float g_fLastPosition[3];
int g_iLastTeleportTick;
float g_fAngleDifference[2];
float g_fLastAngleDifference[2];
// Gain calculation data
int g_strafeTick;
float g_flRawGain;
bool g_bTouchesWall;
int g_iJump;
int g_iTicksOnGround;
float g_iYawSpeed;
int g_iYawTickCount;
int g_iTimingTickCount;
int g_iStrafesDone;
bool g_bFirstSixJumps;
// Strafe analysis data
int g_iStartStrafe_CurrentFrame;
any g_iStartStrafe_Stats_0[MAX_FRAMES];
any g_iStartStrafe_Stats_1[MAX_FRAMES];
any g_iStartStrafe_Stats_2[MAX_FRAMES];
any g_iStartStrafe_Stats_3[MAX_FRAMES];
any g_iStartStrafe_Stats_4[MAX_FRAMES];
any g_iStartStrafe_Stats_5[MAX_FRAMES];
any g_iStartStrafe_Stats_6[MAX_FRAMES];
int g_iStartStrafe_LastRecordedTick;
int g_iStartStrafe_LastTickDifference;
bool g_bStartStrafe_IsRecorded[MAX_FRAMES];
int g_iStartStrafe_IdenticalCount;
int g_iEndStrafe_CurrentFrame;
any g_iEndStrafe_Stats_0[MAX_FRAMES];
any g_iEndStrafe_Stats_1[MAX_FRAMES];
any g_iEndStrafe_Stats_2[MAX_FRAMES];
any g_iEndStrafe_Stats_3[MAX_FRAMES];
any g_iEndStrafe_Stats_4[MAX_FRAMES];
any g_iEndStrafe_Stats_5[MAX_FRAMES];
any g_iEndStrafe_Stats_6[MAX_FRAMES];
int g_iEndStrafe_LastRecordedTick;
int g_iEndStrafe_LastTickDifference;
bool g_bEndStrafe_IsRecorded[MAX_FRAMES];
int g_iEndStrafe_IdenticalCount;
// Key switch analysis data
int g_iKeySwitch_CurrentFrame[2];
any g_iKeySwitch_Stats_0_0[MAX_FRAMES_KEYSWITCH];
any g_iKeySwitch_Stats_0_1[MAX_FRAMES_KEYSWITCH];
any g_iKeySwitch_Stats_1_0[MAX_FRAMES_KEYSWITCH];
any g_iKeySwitch_Stats_1_1[MAX_FRAMES_KEYSWITCH];
any g_iKeySwitch_Stats_2_0[MAX_FRAMES_KEYSWITCH];
any g_iKeySwitch_Stats_2_1[MAX_FRAMES_KEYSWITCH];
bool g_bKeySwitch_IsRecorded_0[MAX_FRAMES_KEYSWITCH];
bool g_bKeySwitch_IsRecorded_1[MAX_FRAMES_KEYSWITCH];
int g_iKeySwitch_LastRecordedTick[2];
// Illegal movement detection data
bool g_iIllegalTurn[MAX_FRAMES];
int g_iIllegalTurn_CurrentFrame;
bool g_iIllegalTurn_IsTiming[MAX_FRAMES];
int g_iLastIllegalReason;
int g_iIllegalSidemoveCount;
int g_iLastIllegalSidemoveCount;
int g_iLastInvalidButtonCount;
int g_iYawChangeCount;
}
// Late load flag
bool g_bLateLoad;
// DHook handles
Handle g_hTeleport; // Handle for the Teleport DHook
// DHook loaded flag
bool g_bDhooksLoaded;
// Forward handles
Handle g_fwdOnDetection; // Forward for cheat detection events
Handle g_fwdOnClientBanned; // Forward for client ban events
// ConVar handles
ConVar g_hBanLength; // Ban length for automated bans
char g_sBanLength[32]; // String representation of the ban length
// ConVar g_hAntiNull; // Whether to punish for null movement stats
// ConVar g_hPrintNullLogs; // Whether to print null movement logs to chat
ConVar g_hAutoban; // Whether to automatically ban detected players
ConVar g_hQueryRate; // How often to query convars from the client
ConVar g_hPersistentData; // Whether to save and reload strafe stats
// Admin mode flag
bool g_bAdminMode[MAXPLAYERS + 1];
// Log file path
char g_aclogfile[PLATFORM_MAX_PATH];
// Player IP addresses
char g_sPlayerIp[MAXPLAYERS + 1][16];
// Persistent data array
ArrayList g_aPersistentData = null;
// Target player for admin commands
int g_iTarget[MAXPLAYERS + 1];
public void OnPluginStart()
{
char sDate[64];
FormatTime(sDate, sizeof(sDate), "%y%m%d", GetTime());
BuildPath(Path_SM, g_aclogfile, PLATFORM_MAX_PATH, "logs/ac_%s.txt", sDate);
UserMsg umVGUIMenu = GetUserMessageId("VGUIMenu");
if (umVGUIMenu == INVALID_MESSAGE_ID)
SetFailState("UserMsg `umVGUIMenu` not found!");
g_hBanLength = CreateConVar("bash_banlength", "0", "Ban length for the automated bans", _, true, 0.0);
g_hAutoban = CreateConVar("bash_autoban", "1", "Auto ban players who are detected", _, true, 0.0, true, 1.0);
HookConVarChange(g_hBanLength, OnBanLengthChanged);
// g_hAntiNull = CreateConVar("bash_antinull", "0", "Punish for null movement stats", _, true, 0.0, true, 1.0);
// g_hPrintNullLogs = CreateConVar("bash_print_null_logs", "0", "Should null logs be print to chat?", _, true, 0.0, true, 1.0);
g_hQueryRate = CreateConVar("bash_query_rate", "0.2", "How often will convars be queried from the client?", _, true, 0.1, true, 2.0);
g_hPersistentData = CreateConVar("bash_persistent_data", "1", "Whether to save and reload strafe stats on a map for players when they disconnect.\nThis is useful to prevent people from frequently rejoining to wipe their strafe stats.", _, true, 0.0, true, 1.0);
AutoExecConfig(true, "bash", "sourcemod");
g_fwdOnDetection = CreateGlobalForward("Bash_OnDetection", ET_Event, Param_Cell, Param_String);
g_fwdOnClientBanned = CreateGlobalForward("Bash_OnClientBanned", ET_Event, Param_Cell);
//HookUserMessage(umVGUIMenu, OnVGUIMenu, true);
g_Engine = GetEngineVersion();
RegAdminCmd("bash2_stats", Bash_Stats, ADMFLAG_GENERIC, "Check a player's strafe stats");
RegAdminCmd("bash2_admin", Bash_AdminMode, ADMFLAG_GENERIC, "Opt in/out of admin mode (Prints bash info into chat).");
RegAdminCmd("bash2_test", Bash_Test, ADMFLAG_RCON, "trigger a test message so you can know if webhooks are working :)");
HookEvent("player_jump", Event_PlayerJump);
RequestFrame(CheckLag);
}
public void OnConfigsExecuted()
{
GetConVarString(g_hBanLength, g_sBanLength, sizeof(g_sBanLength));
}
public void OnBanLengthChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
strcopy(g_sBanLength, sizeof(g_sBanLength), newValue);
}
public void OnAllPluginsLoaded()
{
//g_bTasLoaded = LibraryExists("tas");
if(g_hTeleport == INVALID_HANDLE && LibraryExists("dhooks"))
{
Initialize();
g_bDhooksLoaded = true;
}
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, "tas"))
{
//g_bTasLoaded = true;
}
else if(StrEqual(name, "dhooks") && g_hTeleport == INVALID_HANDLE)
{
Initialize();
g_bDhooksLoaded = true;
}
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, "tas"))
{
//g_bTasLoaded = false;
}
else if(StrEqual(name, "dhooks"))
{
g_bDhooksLoaded = false;
}
}
stock void PrintToAdmins(const char[] msg, any...)
{
char buffer[300];
VFormat(buffer, sizeof(buffer), msg, 2);
for (int i = 1; i <= MaxClients; i++)
{
if (CheckCommandAccess(i, "bash2_chat_log", ADMFLAG_RCON))
{
if(g_bAdminMode[i]) {
PrintToChat(i, buffer);
}
}
}
}
void Initialize()
{
Handle hGameData = LoadGameConfigFile("sdktools.games");
if(hGameData == INVALID_HANDLE)
return;
int iOffset = GameConfGetOffset(hGameData, "Teleport");
CloseHandle(hGameData);
if(iOffset == -1)
return;
g_hTeleport = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, Hook_DHooks_Teleport);
if(g_hTeleport == INVALID_HANDLE){
PrintToServer("\n!! g_hTeleport -> INVALID_HANDLE !!\n");
return;
}
DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
DHookAddParam(g_hTeleport, HookParamType_ObjectPtr);
DHookAddParam(g_hTeleport, HookParamType_VectorPtr);
if(g_Engine == Engine_CSGO)
DHookAddParam(g_hTeleport, HookParamType_Bool); // CS:GO only
}
public MRESReturn Hook_DHooks_Teleport(int client, Handle hParams)
{
if(!IsClientConnected(client) || IsFakeClient(client) || !IsPlayerAlive(client))
return MRES_Ignored;
g_iLastTeleportTick[client] = g_iCmdNum[client];
return MRES_Ignored;
}
void AutoBanPlayer(int client)
{
if(g_hAutoban.BoolValue && IsClientInGame(client) && !IsClientInKickQueue(client))
{
ServerCommand("sm_ban #%d %s Cheating", GetClientUserId(client), g_sBanLength);
Call_StartForward(g_fwdOnClientBanned);
Call_PushCell(client);
Call_Finish();
}
}
float g_fLag_LastCheckTime;
//float g_fLastLagTime;
public void CheckLag(any data)
{
if(GetEngineTime() - g_fLag_LastCheckTime > 0.02)
{
//g_fLastLagTime = GetEngineTime();
}
g_fLag_LastCheckTime = GetEngineTime();
RequestFrame(CheckLag);
}
void SaveOldLogs()
{
char sDate[64];
FormatTime(sDate, sizeof(sDate), "%y%m%d", GetTime() - (60 * 60 * 24)); // Save logs from day before to new file
char sPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sPath, sizeof(sPath), "logs/ac_%s.txt", sDate);
if(!FileExists(sPath))
{
return;
}
char sNewPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sNewPath, sizeof(sNewPath), "logs/bash.txt");
File hOld = OpenFile(sPath, "r");
File hNew = OpenFile(sNewPath, "a");
if(hOld == INVALID_HANDLE)
{
LogError("Couldn't open '%s'", sPath);
return;
}
if(hNew == INVALID_HANDLE)
{
LogError("Couldn't open '%s'", sNewPath);
return;
}
char sDateFormatted[64];
FormatTime(sDateFormatted, sizeof(sDateFormatted), "%y-%m-%d", GetTime() - (60 * 60 * 24));
WriteFileLine(hNew, "\n***** ------------ Logs from %s ------------ *****", sDateFormatted);
char sLine[256];
while(!IsEndOfFile(hOld))
{
if(ReadFileLine(hOld, sLine, sizeof(sLine)))
{
ReplaceString(sLine, sizeof(sLine), "\n", "");
WriteFileLine(hNew, sLine);
}
}
delete hOld;
delete hNew;
DeleteFile(sPath);
}
stock void AnticheatLog(int client, const char[] log, any ...)
{
char buffer[1024];
VFormat(buffer, sizeof(buffer), log, 3);
Call_StartForward(g_fwdOnDetection);
Call_PushCell(client);
Call_PushString(buffer);
Call_Finish();
LogToFile(g_aclogfile, "%L<%s> %s", client, g_sPlayerIp[client], buffer);
/*
if (!g_hPrintNullLogs.BoolValue && StrContains(buffer, "nullPct") != -1)
{
return;
}
*/
PrintToAdmins("%N %s", client, buffer);
}
public Action Event_PlayerJump(Event event, const char[] name, bool dontBroadcast)
{
int iclient = GetClientOfUserId(GetEventInt(event, "userid"));
if(++g_iJump[iclient] == 6)
{
float gainPct = GetGainPercent(iclient);
float yawPct = (float(g_iYawTickCount[iclient]) / float(g_strafeTick[iclient])) * 100.0;
float timingPct = (float(g_iTimingTickCount[iclient]) / float(g_strafeTick[iclient])) * 100.0;
float spj;
if(g_bFirstSixJumps[iclient])
spj = g_iStrafesDone[iclient] / 5.0;
else
spj = g_iStrafesDone[iclient] / 6.0;
if(g_strafeTick[iclient] > 300)
{
if(gainPct > 85.0 && yawPct < 60.0)
{
AnticheatLog(iclient, "has %.2f% gains (Yawing %.1f%, Timing: %.1f%, SPJ: %.1f)", gainPct, yawPct, timingPct, spj);
if(gainPct == 100.0 && timingPct == 100.0)
{
AutoBanPlayer(iclient);
}
}
}
g_iJump[iclient] = 0;
g_flRawGain[iclient] = 0.0;
g_strafeTick[iclient] = 0;
g_iYawTickCount[iclient] = 0;
g_iTimingTickCount[iclient] = 0;
g_iStrafesDone[iclient] = 0;
g_bFirstSixJumps[iclient] = false;
}
return Plugin_Continue;
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
RegPluginLibrary("bash2");
g_bLateLoad = late;
return APLRes_Success;
}
public Action OnVGUIMenu(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
{
int iclient = players[0];
if(g_bMOTDTest[iclient])
{
GetClientEyeAngles(iclient, g_MOTDTestAngles[iclient]);
CreateTimer(0.1, Timer_MOTD, GetClientUserId(iclient));
}
return Plugin_Continue;
}
public Action Timer_MOTD(Handle timer, any data)
{
int iclient = GetClientOfUserId(data);
if(iclient != 0)
{
float vAng[3];
GetClientEyeAngles(iclient, vAng);
if(FloatAbs(g_MOTDTestAngles[iclient][1] - vAng[1]) > 50.0)
{
PrintToAdmins("%N is strafe hacking", iclient);
}
g_bMOTDTest[iclient] = false;
}
return Plugin_Continue;
}
public void OnMapStart()
{
delete g_aPersistentData;
g_aPersistentData = new ArrayList(sizeof(fuck_sourcemod));
CreateTimer(g_hQueryRate.FloatValue, Timer_UpdateYaw, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
if(g_bLateLoad)
{
for(int iclient = 1; iclient <= MaxClients; iclient++)
{
if(IsClientInGame(iclient))
{
OnClientConnected(iclient);
OnClientPutInServer(iclient);
}
}
}
SaveOldLogs();
}
public Action Timer_UpdateYaw(Handle timer, any data)
{
for(int iclient = 1; iclient <= MaxClients; iclient++)
{
if(IsClientInGame(iclient) && !IsFakeClient(iclient))
{
QueryForCvars(iclient);
}
}
return Plugin_Continue;
}
public void OnClientConnected(int client)
{
if(IsFakeClient(client))
return;
GetClientIP(client, g_sPlayerIp[client], 16);
for(int idx; idx < MAX_FRAMES; idx++)
{
g_bStartStrafe_IsRecorded[client][idx] = false;
g_bEndStrafe_IsRecorded[client][idx] = false;
}
for(int idx; idx < MAX_FRAMES_KEYSWITCH; idx++)
{
g_bKeySwitch_IsRecorded[client][BT_Key][idx] = false;
g_bKeySwitch_IsRecorded[client][BT_Move][idx] = false;
}
g_iStartStrafe_CurrentFrame[client] = 0;
g_iEndStrafe_CurrentFrame[client] = 0;
g_iKeySwitch_CurrentFrame[client][BT_Key] = 0;
g_iKeySwitch_CurrentFrame[client][BT_Move] = 0;
g_bCheckedYet[client] = false;
g_iStartStrafe_LastTickDifference[client] = 0;
g_iEndStrafe_LastTickDifference[client] = 0;
g_iStartStrafe_IdenticalCount[client] = 0;
g_iEndStrafe_IdenticalCount[client] = 0;
g_iYawSpeed[client] = 210.0;
g_mYaw[client] = 0.0;
g_mYawChangedCount[client] = 0;
g_mYawCheckedCount[client] = 0;
g_mFilter[client] = false;
g_mFilterChangedCount[client] = 0;
g_mFilterCheckedCount[client] = 0;
g_mRawInput[client] = true;
g_mRawInputChangedCount[client] = 0;
g_mRawInputCheckedCount[client] = 0;
g_mCustomAccel[client] = 0;
g_mCustomAccelChangedCount[client] = 0;
g_mCustomAccelCheckedCount[client] = 0;
g_mCustomAccelMax[client] = 0.0;
g_mCustomAccelMaxChangedCount[client] = 0;
g_mCustomAccelMaxCheckedCount[client] = 0;
g_mCustomAccelScale[client] = 0.0;
g_mCustomAccelScaleChangedCount[client] = 0;
g_mCustomAccelScaleCheckedCount[client] = 0;
g_mCustomAccelExponent[client] = 0.0;
g_mCustomAccelExponentChangedCount[client] = 0;
g_mCustomAccelExponentCheckedCount[client] = 0;
g_Sensitivity[client] = 0.0;
g_SensitivityChangedCount[client] = 0;
g_SensitivityCheckedCount[client] = 0;
// g_JoySensitivity[client] = 0.0;
// g_JoySensitivityChangedCount[client] = 0;
// g_JoySensitivityCheckedCount[client] = 0;
g_ZoomSensitivity[client] = 0.0;
g_ZoomSensitivityChangedCount[client] = 0;
g_ZoomSensitivityCheckedCount[client] = 0;
g_iLastInvalidButtonCount[client] = 0;
g_JoyStick[client] = false;
g_JoyStickChangedCount[client] = 0;
}
public void OnClientPostAdminCheck(int client)
{
if (CheckCommandAccess(client, "bash2_chat_log", ADMFLAG_RCON))
{
g_bAdminMode[client] = true;
}
if(IsFakeClient(client))
return;
if (!g_hPersistentData.BoolValue)
return;
int index = g_aPersistentData.FindValue(GetSteamAccountID(client));
if (index != -1)
{
fuck_sourcemod x;
g_aPersistentData.GetArray(index, x);
g_aPersistentData.Erase(index);
g_iRealButtons[client] = x.g_iRealButtons;
g_iButtons[client] = x.g_iButtons;
g_iLastButtons[client] = x.g_iLastButtons;
g_iLastPressTick[client][0] = x.g_iLastPressTick_0;
g_iLastPressTick[client][1] = x.g_iLastPressTick_1;
g_iLastPressTick[client][2] = x.g_iLastPressTick_2;
g_iLastPressTick[client][3] = x.g_iLastPressTick_3;
g_iLastPressTick_Recorded[client][0] = x.g_iLastPressTick_Recorded_0;
g_iLastPressTick_Recorded[client][1] = x.g_iLastPressTick_Recorded_1;
g_iLastPressTick_Recorded[client][2] = x.g_iLastPressTick_Recorded_2;
g_iLastPressTick_Recorded[client][3] = x.g_iLastPressTick_Recorded_3;
g_iLastPressTick_Recorded_KS[client][0] = x.g_iLastPressTick_Recorded_KS_0;
g_iLastPressTick_Recorded_KS[client][1] = x.g_iLastPressTick_Recorded_KS_1;
g_iLastPressTick_Recorded_KS[client][3] = x.g_iLastPressTick_Recorded_KS_2;
g_iLastPressTick_Recorded_KS[client][3] = x.g_iLastPressTick_Recorded_KS_3;
g_iKeyPressesThisStrafe[client] = x.g_iKeyPressesThisStrafe;
g_iLastReleaseTick[client][0] = x.g_iLastReleaseTick_0;
g_iLastReleaseTick[client][1] = x.g_iLastReleaseTick_1;
g_iLastReleaseTick[client][2] = x.g_iLastReleaseTick_2;
g_iLastReleaseTick[client][3] = x.g_iLastReleaseTick_3;
g_iLastReleaseTick_Recorded[client][0] = x.g_iLastReleaseTick_Recorded_0;
g_iLastReleaseTick_Recorded[client][1] = x.g_iLastReleaseTick_Recorded_1;
g_iLastReleaseTick_Recorded[client][2] = x.g_iLastReleaseTick_Recorded_2;
g_iLastReleaseTick_Recorded[client][3] = x.g_iLastReleaseTick_Recorded_3;
g_iLastReleaseTick_Recorded_KS[client][0] = x.g_iLastReleaseTick_Recorded_KS_0;
g_iLastReleaseTick_Recorded_KS[client][1] = x.g_iLastReleaseTick_Recorded_KS_1;
g_iLastReleaseTick_Recorded_KS[client][2] = x.g_iLastReleaseTick_Recorded_KS_2;
g_iLastReleaseTick_Recorded_KS[client][3] = x.g_iLastReleaseTick_Recorded_KS_3;
g_fLastMove[client] = x.g_fLastMove;
g_iLastTurnDir[client] = x.g_iLastTurnDir;
g_iLastTurnTick[client] = x.g_iLastTurnTick;
g_iLastTurnTick_Recorded_StartStrafe[client] = x.g_iLastTurnTick_Recorded_StartStrafe;
g_iLastTurnTick_Recorded_EndStrafe[client] = x.g_iLastTurnTick_Recorded_EndStrafe;
g_iLastStopTurnTick[client] = x.g_iLastStopTurnTick;
//g_bIsTurning[client] = x.g_bIsTurning;
g_iReleaseTickAtLastEndStrafe[client] = x.g_iReleaseTickAtLastEndStrafe;
g_fLastAngles[client] = x.g_fLastAngles;
g_InvalidButtonSidemoveCount[client] = x.g_InvalidButtonSidemoveCount;
g_iCmdNum[client] = x.g_iCmdNum;
g_fLastPosition[client] = x.g_fLastPosition;
//g_iLastTeleportTick[client] = x.g_iLastTeleportTick;
g_fAngleDifference[client] = x.g_fAngleDifference;
g_fLastAngleDifference[client] = x.g_fLastAngleDifference;
g_strafeTick[client] = x.g_strafeTick;
g_flRawGain[client] = x.g_flRawGain;
g_bTouchesWall[client] = x.g_bTouchesWall;
g_iJump[client] = x.g_iJump;
g_iTicksOnGround[client] = x.g_iTicksOnGround;
g_iYawSpeed[client] = x.g_iYawSpeed;
g_iYawTickCount[client] = x.g_iYawTickCount;
g_iTimingTickCount[client] = x.g_iTimingTickCount;
g_iStrafesDone[client] = x.g_iStrafesDone;
g_bFirstSixJumps[client] = x.g_bFirstSixJumps;
g_iStartStrafe_CurrentFrame[client] = x.g_iStartStrafe_CurrentFrame;
g_iStartStrafe_Stats[client][0] = x.g_iStartStrafe_Stats_0;
g_iStartStrafe_Stats[client][1] = x.g_iStartStrafe_Stats_1;
g_iStartStrafe_Stats[client][2] = x.g_iStartStrafe_Stats_2;
g_iStartStrafe_Stats[client][3] = x.g_iStartStrafe_Stats_3;
g_iStartStrafe_Stats[client][4] = x.g_iStartStrafe_Stats_4;
g_iStartStrafe_Stats[client][5] = x.g_iStartStrafe_Stats_5;
g_iStartStrafe_Stats[client][6] = x.g_iStartStrafe_Stats_6;
g_iStartStrafe_LastRecordedTick[client] = x.g_iStartStrafe_LastRecordedTick;
g_iStartStrafe_LastTickDifference[client] = x.g_iStartStrafe_LastTickDifference;
g_bStartStrafe_IsRecorded[client] = x.g_bStartStrafe_IsRecorded;
g_iStartStrafe_IdenticalCount[client] = x.g_iStartStrafe_IdenticalCount;
g_iEndStrafe_CurrentFrame[client] = x.g_iEndStrafe_CurrentFrame;
g_iEndStrafe_Stats[client][0] = x.g_iEndStrafe_Stats_0;
g_iEndStrafe_Stats[client][1] = x.g_iEndStrafe_Stats_1;
g_iEndStrafe_Stats[client][2] = x.g_iEndStrafe_Stats_2;
g_iEndStrafe_Stats[client][3] = x.g_iEndStrafe_Stats_3;
g_iEndStrafe_Stats[client][4] = x.g_iEndStrafe_Stats_4;
g_iEndStrafe_Stats[client][5] = x.g_iEndStrafe_Stats_5;
g_iEndStrafe_Stats[client][6] = x.g_iEndStrafe_Stats_6;
g_iEndStrafe_LastRecordedTick[client] = x.g_iEndStrafe_LastRecordedTick;
g_iEndStrafe_LastTickDifference[client] = x.g_iEndStrafe_LastTickDifference;
g_bEndStrafe_IsRecorded[client] = x.g_bEndStrafe_IsRecorded;
g_iEndStrafe_IdenticalCount[client] = x.g_iEndStrafe_IdenticalCount;
g_iKeySwitch_CurrentFrame[client] = x.g_iKeySwitch_CurrentFrame;
g_iKeySwitch_Stats[client][0][0] = x.g_iKeySwitch_Stats_0_0;
g_iKeySwitch_Stats[client][0][1] = x.g_iKeySwitch_Stats_0_1;
g_iKeySwitch_Stats[client][1][0] = x.g_iKeySwitch_Stats_1_0;
g_iKeySwitch_Stats[client][1][1] = x.g_iKeySwitch_Stats_1_1;
g_iKeySwitch_Stats[client][2][0] = x.g_iKeySwitch_Stats_2_0;
g_iKeySwitch_Stats[client][2][1] = x.g_iKeySwitch_Stats_2_1;
g_bKeySwitch_IsRecorded[client][0] = x.g_bKeySwitch_IsRecorded_0;
g_bKeySwitch_IsRecorded[client][1] = x.g_bKeySwitch_IsRecorded_1;
g_iKeySwitch_LastRecordedTick[client] = x.g_iKeySwitch_LastRecordedTick;
g_iIllegalTurn[client] = x.g_iIllegalTurn;
g_iIllegalTurn_CurrentFrame[client] = x.g_iIllegalTurn_CurrentFrame;
g_iIllegalTurn_IsTiming[client] = x.g_iIllegalTurn_IsTiming;
g_iLastIllegalReason[client] = x.g_iLastIllegalReason;
g_iIllegalSidemoveCount[client] = x.g_iIllegalSidemoveCount;
g_iLastIllegalSidemoveCount[client] = x.g_iLastIllegalSidemoveCount;
g_iLastInvalidButtonCount[client] = x.g_iLastInvalidButtonCount;
g_iYawChangeCount[client] = x.g_iYawChangeCount;
}
}
public void OnClientPutInServer(int client)
{
if(IsFakeClient(client))
return;
SDKHook(client, SDKHook_Touch, Hook_OnTouch);
if(g_bDhooksLoaded)
{
DHookEntity(g_hTeleport, false, client);
}
QueryForCvars(client);
}
public void OnClientDisconnect(int client)
{
if (GetSteamAccountID(client) != 0 && g_hPersistentData.BoolValue)
{
fuck_sourcemod x;
x.accountid = GetSteamAccountID(client);
x.g_iRealButtons = g_iRealButtons[client];
x.g_iButtons = g_iButtons[client];
x.g_iLastButtons = g_iButtons[client];
x.g_iLastPressTick_0 = g_iLastPressTick[client][0];
x.g_iLastPressTick_1 = g_iLastPressTick[client][1];
x.g_iLastPressTick_2 = g_iLastPressTick[client][2];
x.g_iLastPressTick_3 = g_iLastPressTick[client][3];
x.g_iLastPressTick_Recorded_0 = g_iLastPressTick_Recorded[client][0];
x.g_iLastPressTick_Recorded_1 = g_iLastPressTick_Recorded[client][1];
x.g_iLastPressTick_Recorded_2 = g_iLastPressTick_Recorded[client][2];
x.g_iLastPressTick_Recorded_3 = g_iLastPressTick_Recorded[client][3];
x.g_iLastPressTick_Recorded_KS_0 = g_iLastPressTick_Recorded_KS[client][0];
x.g_iLastPressTick_Recorded_KS_1 = g_iLastPressTick_Recorded_KS[client][1];
x.g_iLastPressTick_Recorded_KS_2 = g_iLastPressTick_Recorded_KS[client][2];
x.g_iLastPressTick_Recorded_KS_3 = g_iLastPressTick_Recorded_KS[client][3];
x.g_iKeyPressesThisStrafe = g_iKeyPressesThisStrafe[client];
x.g_iLastReleaseTick_0 = g_iLastReleaseTick[client][0];
x.g_iLastReleaseTick_1 = g_iLastReleaseTick[client][1];
x.g_iLastReleaseTick_2 = g_iLastReleaseTick[client][2];
x.g_iLastReleaseTick_3 = g_iLastReleaseTick[client][3];
x.g_iLastReleaseTick_Recorded_0 = g_iLastReleaseTick_Recorded[client][0];
x.g_iLastReleaseTick_Recorded_1 = g_iLastReleaseTick_Recorded[client][1];
x.g_iLastReleaseTick_Recorded_2 = g_iLastReleaseTick_Recorded[client][2];
x.g_iLastReleaseTick_Recorded_3 = g_iLastReleaseTick_Recorded[client][3];
x.g_iLastReleaseTick_Recorded_KS_0 = g_iLastReleaseTick_Recorded_KS[client][0];
x.g_iLastReleaseTick_Recorded_KS_1 = g_iLastReleaseTick_Recorded_KS[client][1];
x.g_iLastReleaseTick_Recorded_KS_2 = g_iLastReleaseTick_Recorded_KS[client][2];
x.g_iLastReleaseTick_Recorded_KS_3 = g_iLastReleaseTick_Recorded_KS[client][3];
x.g_fLastMove = g_fLastMove[client];
x.g_iLastTurnDir = g_iLastTurnDir[client];
x.g_iLastTurnTick = g_iLastTurnTick[client];
x.g_iLastTurnTick_Recorded_StartStrafe = g_iLastTurnTick_Recorded_StartStrafe[client];
x.g_iLastTurnTick_Recorded_EndStrafe = g_iLastTurnTick_Recorded_EndStrafe[client];
x.g_iLastStopTurnTick = g_iLastStopTurnTick[client];
x.g_bIsTurning = g_bIsTurning[client];
x.g_iReleaseTickAtLastEndStrafe = g_iReleaseTickAtLastEndStrafe[client];
x.g_fLastAngles = g_fLastAngles[client];
x.g_InvalidButtonSidemoveCount = g_InvalidButtonSidemoveCount[client];
x.g_iCmdNum = g_iCmdNum[client];
x.g_fLastPosition = g_fLastPosition[client];
x.g_iLastTeleportTick = g_iLastTeleportTick[client];
x.g_fAngleDifference = g_fAngleDifference[client];
x.g_fLastAngleDifference = g_fLastAngleDifference[client];
x.g_strafeTick = g_strafeTick[client];
x.g_flRawGain = g_flRawGain[client];
x.g_bTouchesWall = g_bTouchesWall[client];
x.g_iJump = g_iJump[client];
x.g_iTicksOnGround = g_iTicksOnGround[client];
x.g_iYawSpeed = g_iYawSpeed[client];
x.g_iYawTickCount = g_iYawTickCount[client];
x.g_iTimingTickCount = g_iTimingTickCount[client];
x.g_iStrafesDone = g_iStrafesDone[client];
x.g_bFirstSixJumps = g_bFirstSixJumps[client];
x.g_iStartStrafe_CurrentFrame = g_iStartStrafe_CurrentFrame[client];
x.g_iStartStrafe_Stats_0 = g_iStartStrafe_Stats[client][0];
x.g_iStartStrafe_Stats_1 = g_iStartStrafe_Stats[client][1];
x.g_iStartStrafe_Stats_2 = g_iStartStrafe_Stats[client][2];
x.g_iStartStrafe_Stats_3 = g_iStartStrafe_Stats[client][3];
x.g_iStartStrafe_Stats_4 = g_iStartStrafe_Stats[client][4];
x.g_iStartStrafe_Stats_5 = g_iStartStrafe_Stats[client][5];
x.g_iStartStrafe_Stats_6 = g_iStartStrafe_Stats[client][6];
x.g_iStartStrafe_LastRecordedTick = g_iStartStrafe_LastRecordedTick[client];
x.g_iStartStrafe_LastTickDifference = g_iStartStrafe_LastTickDifference[client];
x.g_bStartStrafe_IsRecorded = g_bStartStrafe_IsRecorded[client];
x.g_iStartStrafe_IdenticalCount = g_iStartStrafe_IdenticalCount[client];
x.g_iEndStrafe_CurrentFrame = g_iEndStrafe_CurrentFrame[client];
x.g_iEndStrafe_Stats_0 = g_iEndStrafe_Stats[client][0];
x.g_iEndStrafe_Stats_1 = g_iEndStrafe_Stats[client][1];