Syntax: Select all
random.choice(playerlib.getUseridList('#bot'))
here is what i use in ES to get a random userid
here is what i tried in SP but don't work @@
doesn't print the index
Syntax: Select all
from events import Event
from players.entity import PlayerEntity
from filters.players import PlayerIter
@Event
def player_say(game_event):
new_t = random.choice(PlayerIter('ct'))
print(new_t)
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/events/listener.py', line 90, in fire_game_event
callback(game_event)
File '../addons/source-python/plugins/test/test.py', line 26, in player_say
new_t = random.choice(PlayerIter('ct'))
File '../addons/source-python/Python3/random.py', line 256, in choice
return seq[i]
TypeError: 'PlayerIter' object does not support indexing
from wiki
Code: Select all
from filters.players import PlayerIter
# Usage
# for <variable or variables> in PlayerIter([str/list is_filters], [str/list not_filters], [str/list return_types]):
# Since "index" is the default return type, loop over all player indexes
for index in PlayerIter():
pass
# Since "index" is the default return type
------------------- edit -------------------------------
after searching some more maybe i need to do this
Syntax: Select all
new_t = random.choice(list(PlayerIter('ct')))
away from my comp now can't test >_<