Could you test using this:
Syntax: Select all
def weapon_indexes(
self, classname=None, is_filters=None, not_filters=None):
"""Iterate over all currently held weapons by thier index."""
# Is the weapon array supported for the current game?
if _weapon_prop_length is None:
return
# Loop through the length of the weapon array
for offset in range(_weapon_prop_length):
# Get the player's current weapon at this offset
handle = self.get_property_int(
weapon_manager.myweapons + '%03i' % offset)
# Get the weapon's index
index = index_from_inthandle(handle, raise_exception=False)
# Is this a valid index?
if index == INVALID_ENTITY_INDEX:
# Move onto the next offset
continue
try:
# Get the weapon's edict
edict = Entity(index)
except ValueError:
from players.helpers import edict_from_index
print(edict_from_index(index).get_class_name())
# Get the weapon's classname
weapon_class = edict.get_class_name()
# Was a classname given and the current
# weapon is not of that classname?
if classname is not None and weapon_class != classname:
# Do not yield this index
continue
# Import WeaponClassIter to use its functionality
from filters.weapons import WeaponClassIter
# Was a weapon type given and the
# current weapon is not of that type?
if not (is_filters is None and not_filters is None):
if weapon_class not in list(WeaponClassIter(
is_filters, not_filters, 'classname')):
# Do not yield this index
continue
# Yield the index
yield index
Test that for a while to see what all weapon names are shown. It might encounter an error during the except portion. So, let us know about that if it happens, as well.
I have tried to replicate this on both CS:S and CS:GO, and I cannot get that error to occur. Are you adding/removing bots at different times, by chance, that could cause this? And what do you have your bot_defer_ cvar(s) set to?