Example #1
0
 def add_ban(self, target, duration=0, admin=0, reason=None):
     target_id = SteamID.Parse(uniqueid_from_index(target)).to_uint64()
     if admin == 0:
         admin_id = None
     else:
         admin_id = SteamID.Parse(uniqueid_from_index(admin)).to_uint64()
     ban_record = BanRecord(target_id=target_id,
                            admin_id=admin_id,
                            duration=duration,
                            reason=reason)
     with session_scope() as session:
         session.add(ban_record)
Example #2
0
    def _chosen_value(self, menu, index, option):
        """Store the player's chosen value for the setting."""
        # Get the client's uniqueid
        uniqueid = uniqueid_from_index(index)

        # Set the player's setting
        _player_settings_storage[uniqueid][self.convar] = option.value

        # Send the player a message about their changed setting
        _message.send(index, convar=self.convar, value=option.value)
    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()
    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()
Example #5
0
    def _chosen_value(self, menu, index, option):
        """Store the player's chosen value for the setting."""
        uniqueid = uniqueid_from_index(index)

        if option.value == 'Save':
            value = self.current_values[uniqueid]

            # Set the player's setting
            _player_settings_storage[uniqueid][self.convar] = value
            self._send_chosen_message(index, value)
            del self.current_values[uniqueid]
            return

        new_value = self.current_values[uniqueid] + option.value
        if self.min is not None:
            new_value = max(new_value, self.min)
        if self.max is not None:
            new_value = min(new_value, self.max)
        self.current_values[uniqueid] = new_value
        self.menu.send()
    def _chosen_value(self, menu, index, option):
        """Store the player's chosen value for the setting."""
        uniqueid = uniqueid_from_index(index)

        if option.value == 'Save':
            value = self.current_values[uniqueid]

            # Set the player's setting
            _player_settings_storage[uniqueid][self.convar] = value
            self._send_chosen_message(index, value)
            del self.current_values[uniqueid]
            return

        new_value = self.current_values[uniqueid] + option.value
        if self.min is not None:
            new_value = max(new_value, self.min)
        if self.max is not None:
            new_value = min(new_value, self.max)
        self.current_values[uniqueid] = new_value
        self.menu.send()
Example #7
0
 def _chosen_value(self, menu, index, option):
     """Store the player's chosen value for the setting."""
     # Set the player's setting
     uniqueid = uniqueid_from_index(index)
     _player_settings_storage[uniqueid][self.convar] = option.value
     self._send_chosen_message(index, option.value)
 def _chosen_value(self, menu, index, option):
     """Store the player's chosen value for the setting."""
     # Set the player's setting
     uniqueid = uniqueid_from_index(index)
     _player_settings_storage[uniqueid][self.convar] = option.value
     self._send_chosen_message(index, option.value)