Hello,
How can I make a list of the players spectators with their playernames?
Lets say Player1 is alive and Player 2 and Player 3 are spectating him, so how can you return ["Player 2", "Player 3"]?
Sorry Mobilecorrector
Spectator List
Syntax: Select all
from filters.players import PlayerIter
from players.entity import Player
def get_spectators(index):
"""Return a list of names of all players observing the given player."""
player = Player(index)
observer_list = list()
for other in PlayerIter('dead'):
if player.inthandle == other.observer_target:
observer_list.append(other.name)
return observer_list
I have added a "spectators" property to the player class based on your implementation:
https://github.com/Source-Python-Dev-Team/Source.Python/commit/dee963986abb17d83c1d091c0e80fb448e842a12
https://github.com/Source-Python-Dev-Team/Source.Python/commit/dee963986abb17d83c1d091c0e80fb448e842a12
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 97 guests