Page 1 of 1

[CSGO] How to iter over ct and t spawns?

Posted: Thu Dec 29, 2016 12:49 am
by silviogreuel
How can I iter over T and CT spawns?

https://developer.valvesoftware.com/wiki/Info_player_terrorist
https://developer.valvesoftware.com/wiki/Info_player_counterterrorist

I don't know what I am doing wrong

Syntax: Select all

from commands.say import SayCommand
from messages import SayText2
from filters.entities import EntityIter
from players.entity import Player


from cvars.public import PublicConVar
from cvars import ConVarFlags
from plugins.info import PluginInfo

info = PluginInfo()
info.name = "spawn"
info.author = "Silvio Greuel <silviogreuel@gmail.com>"
info.version = "1.0.0"
info.basename = "spawn"
info.variable = "{}_version".format(info.basename)
info.convar = PublicConVar(info.variable, info.version, "{} Version".format(info.name), ConVarFlags.NONE)



@SayCommand('!spawns')
def spawns_cmd(command, playerindex, teamonly):
for entity in EntityIter('info_player_terrorist'):
print('T')
print(dir(entity))
for entity in EntityIter('info_player_counterterrorist'):
print('CT')
print(dir(entity))


Thanks!

Re: [CSGO] How to iter over ct and t spawns?

Posted: Thu Dec 29, 2016 12:01 pm
by Ayuto
That code is actually correct for (probably) all games except CS:GO. In CS:GO it seems like the two entities aren't networked anymore. That means you have to use e.g. BaseEntityIter to iterate over the spawns:

Syntax: Select all

from filters.entities import BaseEntityIter

print('T')
for entity in BaseEntityIter('info_player_terrorist'):
print(entity)

print('CT')
for entity in BaseEntityIter('info_player_counterterrorist'):
print(entity)