Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. from engines.server import server
  2. from listeners import OnClientActive
  3. from listeners import OnClientDisconnect
  4. from players import PlayerGenerator
  5. from entities.helpers import index_from_edict
  6.  
  7. from .entity import TimerPlayer
  8.  
  9. players = []
  10. playerdict = {}
  11.  
  12. # Was plugin loaded during the game?
  13. if server.is_active():
  14.     for edict in PlayerGenerator():
  15.         index = index_from_edict(edict)
  16.  
  17.         player = TimerPlayer(index)
  18.  
  19.         # Update the containers.
  20.         players.append(player)
  21.         playerdict[index] = player
  22.  
  23. # Player fully loaded.
  24. @OnClientActive
  25. def on_client_active(index):
  26.     player = TimerPlayer(index)
  27.  
  28.     # Update the containers.
  29.     players.append(player)
  30.     playerdict[index] = player
  31.    
  32. @OnClientDisconnect
  33. def on_client_disconnect(index):
  34.  
  35.     # Was player fully loaded?
  36.     if index in playerdict:
  37.  
  38.         # Get the player instance.
  39.         player = playerdict[index]
  40.  
  41.         # Remove the player instance from the list.
  42.         players.remove(player)
  43.  
  44.         # Finally, clear the dict.
  45.         del playerdict[index]