Exemplo n.º 1
0
def get_client_language(index):
    """Return the language of the given client.

    :param int index: Index of the client.
    """
    from players.entity import Player
    if Player(index).is_bot():
        return ''

    return engine_server.get_client_convar_value(index, 'cl_language')
Exemplo n.º 2
0
def get_client_language(index):
    """Return the language of the given client.

    :param int index: Index of the client.
    """
    from players.helpers import playerinfo_from_index
    playerinfo = playerinfo_from_index(index)
    if playerinfo.is_fake_client() or 'BOT' in playerinfo.steamid:
        return ''

    return engine_server.get_client_convar_value(index, 'cl_language')
Exemplo n.º 3
0
def get_client_language(index):
    """Return the language of the given client.

    :param int index: Index of the client.
    """
    from players.helpers import playerinfo_from_index
    playerinfo = playerinfo_from_index(index)
    if playerinfo.is_fake_client() or 'BOT' in playerinfo.steamid:
        return ''

    return engine_server.get_client_convar_value(index, 'cl_language')
Exemplo n.º 4
0
    def get_setting(self, index):
        """Return the setting value for the given player index."""
        if Player(index).is_fake_client():
            return self._get_default_value()

        # Get the client's convar value
        value = engine_server.get_client_convar_value(index, self.convar)

        # Try to typecast the value, suppressing ValueErrors
        try:

            # Typecast the given value
            value = self._typecast_value(value)

            # Is the given value a proper one for the convar?
            if self._is_valid_setting(value):

                # If so, return the value
                return value

        except ValueError:
            pass

        # Get the client's uniqueid
        uniqueid = uniqueid_from_index(index)

        # Is the uniqueid in the setting's storage dictionary?
        if uniqueid in _player_settings_storage:

            # Is the convar in the clients's dictionary?
            if self.convar in _player_settings_storage[uniqueid]:

                # Get the client's value for the convar
                value = _player_settings_storage[uniqueid][self.convar]

                # Try to typecast the value, suppressing ValueErrors
                try:

                    # Typecast the given value
                    value = self._typecast_value(value)

                    # Is the given value a proper one for the convar?
                    if self._is_valid_setting(value):

                        # Return the value
                        return value

                except ValueError:
                    pass

        # Return the default value
        return self._get_default_value()
Exemplo n.º 5
0
    def get_setting(self, index):
        """Return the setting value for the given player index."""
        if Player(index).is_fake_client():
            return self._get_default_value()

        # Get the client's convar value
        value = engine_server.get_client_convar_value(index, self.convar)

        # Try to typecast the value, suppressing ValueErrors
        with suppress(ValueError):

            # Typecast the given value
            value = self._typecast_value(value)

            # Is the given value a proper one for the convar?
            if self._is_valid_setting(value):

                # If so, return the value
                return value

        # Get the client's uniqueid
        uniqueid = uniqueid_from_index(index)

        # Is the uniqueid in the setting's storage dictionary?
        if uniqueid in _player_settings_storage:

            # Is the convar in the clients's dictionary?
            if self.convar in _player_settings_storage[uniqueid]:

                # Get the client's value for the convar
                value = _player_settings_storage[uniqueid][self.convar]

                # Try to typecast the value, suppressing ValueErrors
                with suppress(ValueError):

                    # Typecast the given value
                    value = self._typecast_value(value)

                    # Is the given value a proper one for the convar?
                    if self._is_valid_setting(value):

                        # Return the value
                        return value

        # Return the default value
        return self._get_default_value()
Exemplo n.º 6
0
 def get_client_convar_value(self, name):
     """Wrapper for :meth:`engines.server.engine_server.get_client_convar_value`."""
     return engine_server.get_client_convar_value(self.index, name)
Exemplo n.º 7
0
def get_client_language(index):
    """Return the language of the given client."""
    return engine_server.get_client_convar_value(index, 'cl_language')