#1

^^^^^^^^
Reply
#2

pawn Код:
stock SelectRandomPlayer()
{
    new Prandom = random(MAX_PLAYERS);
    if(IsPlayerConnected(Prandom))
    {
       return Prandom;
    }
    else
    {
       return SelectRandomPlayer();
    }
}
Reply
#3

Use Iter_Random in foreach. Also, that code could still return a non-connected player ID.
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Also, that code could still return a non-connected player ID.
how..?
Reply
#5

Okay I failed and didn't see the recursion. But still, you should use Iter_Random in foreach(). Also, a while() loop would be better than recursion.
Reply
#6

Quote:

They aren't connected either, but i'll still return the ID..

wtf? wrong.. it will keep looping until it finds connected... possibly going infinite if server is empty..
why would it stop there.. lol
Reply
#7

Re-read please - I fucked up :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)