argh csgo is so stupid
after you choose to switch team your teamid still stay on the old team
so is it possible for playeriter to include a filter that includes the pending team change??
example: 1 T and 2 CT
1 CT decided to change team to T
len(PlayerIter('t')) == 1 --> should be 2 since one of the CT decided to join T
after next round starts
len(PlayerIter('t')) == 2
playeriter to count the number or pending team change
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
I don't think adding that to PlayerIter is a good idea cause well, while it is pending, you are "still" in your current team... Also, you can always check that yourself.
Syntax: Select all
from filters.players import PlayerIter
from players.entity import PlayerEntity
def get_players_in_or_pending_team(team_index):
# Loop through all players' index/edict instance...
for player_index, player_edict in PlayerIter(
return_types=['index', 'edict']):
# Is the player team not matching the given one?
if (player_edict.get_prop_int('m_iTeamNum') != team_index and
# Is the player pending team not matching the given one?
player_edict.get_prop_int('m_iPendingTeamNum') != team_index):
# If so, no need to go further...
continue
# Get a PlayerEntity instance from the current index and yield it...
yield PlayerEntity(player_index)
L'In20Cible wrote:I don't think adding that to PlayerIter is a good idea cause well, while it is pending, you are "still" in your current team... Also, you can always check that yourself.Syntax: Select all
from filters.players import PlayerIter
from players.entity import PlayerEntity
def get_players_in_or_pending_team(team_index):
# Loop through all players' index/edict instance...
for player_index, player_edict in PlayerIter(
return_types=['index', 'edict']):
# Is the player team not matching the given one?
if (player_edict.get_prop_int('m_iTeamNum') != team_index and
# Is the player pending team not matching the given one?
player_edict.get_prop_int('m_iPendingTeamNum') != team_index):
# If so, no need to go further...
continue
# Get a PlayerEntity instance from the current index and yield it...
yield PlayerEntity(player_index)
could you show me an example how i would use this in a script?
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Syntax: Select all
for player in get_players_in_or_pending_team(2):
print(player.name, 'is terrorist!')
Syntax: Select all
print('There is', len(set(get_players_in_or_pending_team(3))),
'counter-terrorists!')
L'In20Cible wrote:Syntax: Select all
for player in get_players_in_or_pending_team(2):
print(player.name, 'is terrorist!')Syntax: Select all
print('There is', len(set(get_players_in_or_pending_team(3))),
'counter-terrorists!')
ok thanks!
but could you comment the code? having a hard time understanding whats going on :D :p
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 123 guests