@@ -19,52 +19,95 @@ class TestPlayerInputs:
1919    def  OnPluginLoad (self ):
2020        alog ("" )
2121        pass 
22- 
23-     def  OnGameFrame (self , 
24-         simulating : bool ,
25-         bFirstTick : bool ,
26-         bLastTick : bool 
27-         ):
28-         #we will be only reporting button presses on frames where the state changed. 
29-         pass 
30-     def  OnPlayer______ (self , 
31-         _slot : int 
32-         ):
33-         alog ("START" )
22+     def  _checkButtonStates (self , _slot ):
3423        try :
3524            alog ("_slot: "  +  str (_slot ))
3625            player  =  ADVPlayer (_slot )
3726            if  (player .IsValid ()):
38-                 name  =  player .GetName ()
39-                 if  (name ):
40-                     alog (name  +  " is airborn!" )
41-                 else :
42-                     alog ("name was invalid" )
27+                 bstates  =  player .GetButtonStates ()
28+ 
29+                 #incomplete list, missing weapon select 1,2,3,4 (eg) 
30+                 IN_ATTACK  =      1  <<  0 
31+                 alog (str (bstates  &  IN_ATTACK ) +  " IN_ATTACK" )
32+                 IN_JUMP  =        1  <<  1 
33+                 alog (str (bstates  &  IN_JUMP ) +  " IN_JUMP" )
34+                 IN_DUCK  =        1  <<  2 
35+                 alog (str (bstates  &  IN_DUCK ) +  " IN_DUCK" )
36+                 IN_FORWARD  =     1  <<  3 
37+                 alog (str (bstates  &  IN_FORWARD ) +  " IN_FORWARD" )
38+                 IN_BACKWARD  =    1  <<  4 
39+                 alog (str (bstates  &  IN_BACKWARD ) +  " IN_BACKWARD" )
40+                 IN_USE  =         1  <<  5 
41+                 alog (str (bstates  &  IN_USE ) +  " IN_USE" )
42+ 
43+                 #6 
44+                 #7 
45+                 #8 
46+ 
47+                 IN_MOVELEFT  =    1  <<  9 
48+                 alog (str (bstates  &  IN_MOVELEFT ) +  " IN_MOVELEFT" )
49+                 IN_MOVERIGHT  =   1  <<  10 
50+                 alog (str (bstates  &  IN_MOVERIGHT ) +  " IN_MOVERIGHT" )
51+                 IN_ATTACK2  =     1  <<  11 
52+                 alog (str (bstates  &  IN_ATTACK2 ) +  " IN_ATTACK2" )
53+ 
54+                 #12 
55+ 
56+                 IN_RELOAD  =      1  <<  13 
57+                 alog (str (bstates  &  IN_RELOAD ) +  " IN_RELOAD" )
58+ 
59+                 #14 
60+                 #15 
61+ 
62+                 IN_SPRINT  =      1  <<  16 
63+                 alog (str (bstates  &  IN_SPRINT ) +  " IN_SPRINT" )
64+ 
65+                 IN_SCORE  =  0x200000000 
66+                 alog (str (bstates  &  IN_SCORE ) +  " IN_SCORE" )
67+                 IN_LOOK_AT_WEAPON  =  0x800000000 
68+                 alog (str (bstates  &  IN_LOOK_AT_WEAPON ) +  " IN_LOOK_AT_WEAPON" )
69+ 
4370        except  Exception  as  e :
4471            alog (e )
45-             alog (traceback .format_exc ())
72+             alog (traceback .format_exc ())        
73+     def  OnClientCommand (self ,
74+         _slot : int ,
75+         _cmd : str ):
76+         player  =  ADVPlayer (_slot )
77+         if  (player .IsValid ()):
78+             self ._checkButtonStates (self , _slot )
79+             alog (player .GetName () +  " used a ClientCommand: {0}" .format (_cmd ))
80+         pass 
81+     def  OnClientAbility1 (self ,
82+         _slot : int 
83+         ):
84+         player  =  ADVPlayer (_slot )
85+         if  (player .IsValid ()):
86+             self ._checkButtonStates (self , _slot )
87+             alog (player .GetName () +  " used Ability1!" )
88+         pass 
89+     def  OnClientAbility2 (self ,
90+         _slot : int 
91+         ):
92+         player  =  ADVPlayer (_slot )
93+         if  (player .IsValid ()):
94+             self ._checkButtonStates (self , _slot )
95+             alog (player .GetName () +  " used Ability2!" )
96+         pass 
97+     def  OnClientUltimate (self ,
98+         _slot : int 
99+         ):
100+         player  =  ADVPlayer (_slot )
101+         if  (player .IsValid ()):
102+             self ._checkButtonStates (self , _slot )
103+             alog (player .GetName () +  " used Ultimate!" )
104+         pass 
105+     def  OnPlayerJump (self , 
106+         _slot : int 
107+         ):
108+         alog ("START" )
109+         self ._checkButtonStates (self , _slot )
46110        alog ("END" )
47111        pass 
48112
49113
50- '''button_flags =  
51- { 
52-     "IN_NONE":          0x0, 
53-     "IN_ALL":           0xffffffffffffffff, 
54-     "IN_ATTACK":        0x1, 
55-     "IN_JUMP":          0x2, 
56-     "IN_DUCK":          0x4, 
57-     "IN_FORWARD":       0x8, 
58-     "IN_BACK":          0x10, 
59-     "IN_USE":           0x20, 
60-     "IN_TURNLEFT":      0x80, 
61-     "IN_TURNRIGHT":     0x100, 
62-     "IN_MOVELEFT":      0x200, 
63-     "IN_MOVERIGHT":     0x400, 
64-     "IN_ATTACK2":       0x800, 
65-     "IN_RELOAD":        0x2000, 
66-     "IN_SPEED":         0x10000, 
67-     "IN_JOYAUTOSPRINT": 0x20000, 
68- 
69- }''' 
70- 
0 commit comments