Commit bf8db3f Picoseconds
committed
1 parent 69df8f1 commit bf8db3f Copy full SHA for bf8db3f
File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Player from "./Player";
3
3
4
4
export default class Client {
5
5
public tribeJoinQueue : Player [ ] = [ ] ;
6
+ public lastAttackTime = 0 ;
6
7
7
8
constructor (
8
9
public id : string ,
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ import { WeaponVariant } from './Weapons';
22
22
23
23
let currentGame : Game | null = null ;
24
24
25
+ const DEFAULT_MAX_CPS = 25 ;
26
+
27
+ let MAX_CPS = ( process . env . MAX_CPS && parseInt ( process . env . MAX_CPS , 10 ) ) || DEFAULT_MAX_CPS ;
28
+ if ( isNaN ( MAX_CPS ) ) MAX_CPS = DEFAULT_MAX_CPS ;
29
+
25
30
interface DBSchema {
26
31
bannedIPs : string [ ] ;
27
32
moderatorIPs : string [ ] ;
@@ -830,10 +835,19 @@ export default class Game {
830
835
case PacketType . ATTACK :
831
836
if ( client . player ) {
832
837
if ( packet . data [ 0 ] ) {
838
+ if ( Date . now ( ) - client . lastAttackTime < 1000 / MAX_CPS ) {
839
+ client . lastAttackTime = Date . now ( ) ;
840
+ return ;
841
+ }
842
+
843
+ client . lastAttackTime = Date . now ( ) ;
844
+
833
845
this . normalAttack ( client . player ) ;
834
846
} else {
835
847
client . player . isAttacking = false ;
836
848
}
849
+ } else {
850
+ this . kickClient ( client , "Kicked for hacks" ) ;
837
851
}
838
852
break ;
839
853
case PacketType . PLAYER_MOVE :
You can’t perform that action at this time.
0 commit comments