That makes no sense... get_maxplayers() doesn't change and surely can't be 0.
And like I said, even if you limit the loops to, let's say, the total number of players, it can't guarantee you'll pick every player and you can miss out players... so listen and use the method from that thread to pick random players.