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

Please post any questions about developing your plugin here. Please use the search function before posting!
silviogreuel
Junior Member
Posts: 6
Joined: Sat Jun 20, 2015 5:21 pm

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

Postby silviogreuel » Thu Dec 29, 2016 12:49 am

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!
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Thu Dec 29, 2016 12:01 pm

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)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 21 guests