EntityIter
Posted: Mon Apr 07, 2014 10:29 pm
Since EntityIter was just added yesterday, I thought it would be a good idea to post an example. Just like PlayerIter, WeaponEdictIter, and WeaponClassIter, it will iterate of objects of your liking and yield values of the types you wish. Unlike the other three, there are no "is" or "not" filters. Instead, you pass in a full or partial entity classname or a list of full or partial entity classnames as the first argument. The second argument is a boolean as to whether you want to match full names only or allow partials. The third is the return types, just like the other 3 generators:
Current return types are:
Syntax: Select all
from filters.entities import EntityIter
# Loop through all entities and get their index, Pointer instance, and classname
for index, pointer, classname in EntityIter(return_types=['index', 'pointer', 'classname']):
print(index, pointer, classname)
# Loop through all weapon entities on the server and get their inthandles
# Notice the use of "False" as the second argument to allow all entity classnames with weapon_ to be iterated over
for handle in EntityIter('weapon_', False, 'inthandle'):
print(handle)
# Loop through all players
# Note the use of "True" as the second argument. "player" can also be found in other entity
# classnames, so using True makes sure only entities with the "player" classname are iterated over
for index in EntityIter('player', True, 'index'):
print(index)
Current return types are:
- index
- edict
- basehandle
- inthandle
- pointer
- classname