Пример #1
0
def _initialize_players():
    for i in range(1, global_vars.max_clients + 1):
        try:
            edict = edict_from_index(i)
        except ValueError:
            pass
        else:
            baseplayer = BasePlayer(i)
            baseplayer._edict = edict
            baseplayer._userid = userid_from_edict(edict)
            baseplayer._name = playerinfo_from_edict(edict).name
            baseplayer._connected = True
            baseplayer._fake_client = playerinfo_from_edict(
                edict).is_fake_client()

            if baseplayer._fake_client:
                baseplayer._accountid = baseplayer._name
                baseplayer._steamid2 = 'BOT'
                baseplayer._uniqueid = f'BOT_{baseplayer.name}'
                baseplayer._authorized = True

                OnClientAuthorized.manager.notify(baseplayer)
            else:
                if engine_server.is_client_fully_authenticated(
                        baseplayer.edict):
                    _initialize(baseplayer)
                else:
                    _authenticate.add(baseplayer)
Пример #2
0
def _initialize(baseplayer):
    # Wait until we can retrieve a playerinfo from the baseplayer (prevents a lot of errors further on)
    try:
        playerinfo_from_edict(baseplayer.edict)
    except ValueError:
        pass
    else:
        steamid = engine_server.get_client_steamid(baseplayer._edict)

        _authenticate.discard(baseplayer)

        baseplayer._accountid = steamid.account_id
        baseplayer._uniqueid = baseplayer._steamid2 = steamid.to_steamid2()
        baseplayer._steamid3 = steamid.to_steamid3()
        baseplayer._authorized = True

        OnClientAuthorized.manager.notify(baseplayer)

    # Are there no more human players waiting to get authenticated?
    if not _authenticate:
        for baseplayer in _bots:
            OnClientAuthorized.manager.notify(baseplayer)

        _bots.clear()
Пример #3
0
def _initialize(baseplayer):
    # Wait until we can retrieve a playerinfo from the baseplayer (prevents a lot of errors further on)
    try:
        playerinfo = playerinfo_from_edict(baseplayer.edict)
    except ValueError:
        pass
    else:
        steamid = engine_server.get_client_steamid(baseplayer._edict)

        _authenticate.discard(baseplayer)

        baseplayer._accountid = steamid.account_id
        baseplayer._uniqueid = baseplayer._steamid2 = playerinfo.steamid  # steamid.to_steamid2()
        baseplayer._steamid3 = steamid.to_steamid3()
        baseplayer._authorized = True

        OnClientAuthorized.manager.notify(baseplayer)
Пример #4
0
 def _player_is_on_team(self, edict):
     """Return whether the player is on the team."""
     return playerinfo_from_edict(edict).get_team_index() == self.team
Пример #5
0
    def __init__(self, team):
        """Store the team number for future use."""
        self.team = team

    def _player_is_on_team(self, edict):
        """Return whether the player is on the team."""
        return playerinfo_from_edict(edict).get_team_index() == self.team


# =============================================================================
# >> FILTERS
# =============================================================================
# Register the filter functions
_player_iter_manager.register_filter('all', lambda edict: True)
_player_iter_manager.register_filter(
    'bot', lambda edict: playerinfo_from_edict(edict).is_fake_client())
_player_iter_manager.register_filter(
    'human', lambda edict: not playerinfo_from_edict(edict).is_fake_client())
_player_iter_manager.register_filter(
    'alive', lambda edict: not PlayerEntity(index_from_edict(
        edict)).dead_flag)
_player_iter_manager.register_filter(
    'dead', lambda edict: PlayerEntity(index_from_edict(
        edict)).dead_flag)

# Loop through all teams in the game's team file
for _team in _game_teams.get('names', {}):

    # Add the team to the _player_teams dictionary
    _player_teams[_team] = int(_game_teams['names'][_team])