@@ -33,32 +33,33 @@ def OnGameFrame(self,
3333            #note that just being in this list does not mean your actually in the air 
3434            #just that airborn/ladder/grounded state is being tracked. 
3535            player  =  ADVPlayer (_slot )
36-             grounded  =  player .IsOnGround ()
37-             if  not  grounded :
38-                 if  player .IsOnLadder (): 
39-                     grounded  =  1  #ladders count as ground too. 
40-                 ''' 
41-                 if player.inWater(): 
42-                     figure out how to figure out. 
43-                     grounded = 1 
44-                 ''' 
36+             if  (player .IsValid ()):
37+                 grounded  =  player .IsOnGround ()
38+                 if  not  grounded :
39+                     if  player .IsOnLadder (): 
40+                         grounded  =  1  #ladders count as ground too. 
41+                     ''' 
42+                     if player.inWater(): 
43+                         figure out how to figure out. 
44+                         grounded = 1 
45+                     ''' 
4546
46-             if  self .last_grounded .get (_slot , 1 ) !=  grounded :
47-                 #if the last grounded state does not match what you are now, like 
48-                 #if you fall off a box, ladder, or roof... or jump :) 
49-                 self .last_grounded [_slot ] =  grounded 
50-                 if  grounded :
51-                     ev  =  Source2Py .CreateFakeEvent ("player_land" , True )
52-                     if  (ev ):
53-                         geks  =  Source2Py .GameEventKeySymbol_t ("userid" )
54-                         ev .SetInt (geks , _slot )
55-                         Source2Py .FireFakeEvent (ev , True )
56-                 else :
57-                     ev  =  Source2Py .CreateFakeEvent ("player_airborn" , True )
58-                     if  (ev ):
59-                         geks  =  Source2Py .GameEventKeySymbol_t ("userid" )
60-                         ev .SetInt (geks , _slot )
61-                         Source2Py .FireFakeEvent (ev , True )
47+                  if  self .last_grounded .get (_slot , 1 ) !=  grounded :
48+                      #if the last grounded state does not match what you are now, like 
49+                      #if you fall off a box, ladder, or roof... or jump :) 
50+                      self .last_grounded [_slot ] =  grounded 
51+                      if  grounded :
52+                          ev  =  Source2Py .CreateFakeEvent ("player_land" , True )
53+                          if  (ev ):
54+                              geks  =  Source2Py .GameEventKeySymbol_t ("userid" )
55+                              ev .SetInt (geks , _slot )
56+                              Source2Py .FireFakeEvent (ev , True )
57+                      else :
58+                          ev  =  Source2Py .CreateFakeEvent ("player_airborn" , True )
59+                          if  (ev ):
60+                              geks  =  Source2Py .GameEventKeySymbol_t ("userid" )
61+                              ev .SetInt (geks , _slot )
62+                              Source2Py .FireFakeEvent (ev , True )
6263
6364        pass 
6465    def  OnPlayerJump (self , 
@@ -81,11 +82,12 @@ def OnPlayerJump(self,
8182        try :
8283            self .players_in_air [_slot ] =  True 
8384            player  =  ADVPlayer (_slot )
84-             name  =  player .GetName ()
85-             if  (name ):
86-                 alog (name  +  " jumped!" )
87-             else :
88-                 alog ("player.GetName() returned nullptr (jumped!)" )
85+             if  (player .IsValid ()):
86+                 name  =  player .GetName ()
87+                 if  (name ):
88+                     alog (name  +  " jumped!" )
89+                 else :
90+                     alog ("player.GetName() returned nullptr (jumped!)" )
8991        except  Exception  as  e :
9092            alog (e )
9193            alog (traceback .format_exc ())
@@ -121,12 +123,12 @@ def OnPlayerLand(self,
121123        try :
122124            alog ("_slot: "  +  str (_slot ))
123125            player  =  ADVPlayer (_slot )
124-             name   =   player .GetName () 
125-             if  ( name ): 
126-                 alog (name   +   " landed!" ) 
127-             else : 
128-                 alog ( "player.GetName() returned nullptr (landed!)" ) 
129- 
126+             if  ( player .IsValid ()): 
127+                  name   =   player . GetName () 
128+                 if   (name ): 
129+                      alog ( name   +   " landed!" ) 
130+                 else : 
131+                      alog ( "player.GetName() returned nullptr (landed!)" ) 
130132        except  Exception  as  e :
131133            alog (e )
132134            alog (traceback .format_exc ())
@@ -142,11 +144,12 @@ def OnPlayerAirborn(self,
142144        try :
143145            alog ("_slot: "  +  str (_slot ))
144146            player  =  ADVPlayer (_slot )
145-             name  =  player .GetName ()
146-             if  (name ):
147-                 alog (name  +  " is airborn!" )
148-             else :
149-                 alog ("player.GetName() returned nullptr (is airborn!)" )
147+             if  (player .IsValid ()):
148+                 name  =  player .GetName ()
149+                 if  (name ):
150+                     alog (name  +  " is airborn!" )
151+                 else :
152+                     alog ("player.GetName() returned nullptr (is airborn!)" )
150153        except  Exception  as  e :
151154            alog (e )
152155            alog (traceback .format_exc ())
0 commit comments