Skip to content

players.weapons._PlayerWeapons is not completely updated #86

Description

@KirillMysnik

The class is not completely updated to use new conversion functions. I'm talking about this update: http://forums.sourcepython.com/showthread.php?991-Updated-conversion-functions&p=6402&viewfull=1#post6402

Some parts of it still use outdated calls to these functions. Take a look at get_weapon_color and set_weapon_color:

        # Get the weapon's BaseHandle instance
        index = index_from_inthandle(handle)

        # Was no index found?
        if index is None:

            # Raise an error
            raise ValueError(
                'No active weapon found for player "{0}"'.format(self.userid))

If the active weapon is already dropped and there're no more valid weapons on player, index_from_inthandle will raise an exception. It won't return None.
As a result, instead of getting
ValueError: No active weapon found for player "2"
we will get
ValueError: Unable to get an index from the given IntHandle (-1)

The comment is also misleading. We're getting an index there, not BaseHandle instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions