Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from engines.server import server
- from listeners import OnClientActive
- from listeners import OnClientDisconnect
- from players import PlayerGenerator
- from entities.helpers import index_from_edict
- from .entity import TimerPlayer
- players = []
- playerdict = {}
- # Was plugin loaded during the game?
- if server.is_active():
- for edict in PlayerGenerator():
- index = index_from_edict(edict)
- player = TimerPlayer(index)
- # Update the containers.
- players.append(player)
- playerdict[index] = player
- # Player fully loaded.
- @OnClientActive
- def on_client_active(index):
- player = TimerPlayer(index)
- # Update the containers.
- players.append(player)
- playerdict[index] = player
- @OnClientDisconnect
- def on_client_disconnect(index):
- # Was player fully loaded?
- if index in playerdict:
- # Get the player instance.
- player = playerdict[index]
- # Remove the player instance from the list.
- players.remove(player)
- # Finally, clear the dict.
- del playerdict[index]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement