18.01.2017, 12:30
There's nothing random about it. It just picks the first player in that team all the time. I will suggest using foreach and custom iterators; one for each team. Then you can use Iter_Rand(). Otherwise you can get by with a do-while loop but you must be cautious to not let it run infinitely.
Again, foreach is probably the better option.
PHP код:
GetRandomPlayerInTeam(teamdef)
{
new
randomPlayer = INVALID_PLAYER_ID,
maxId = GetPlayerPoolSize(),
loopGuard = 1000;
do
{
randomPlayer = random(maxId);
}
while(team[randomPlayer] != teamdef && --loopGuard > 0);
return (loopGuard <= 0) ? INVALID_PLAYER_ID : randomPlayer;
}