Random?
#2

pawn Код:
stock SelectRandomPlayer()
{
     new random = Random(MAX_PLAYERS);
     if(IsPlayerConnected(random))
     {
           return random;
     }
     else
     {
           SelectRandomPlayer();
     }
}
Now you can use it for example like this:
pawn Код:
new randomplayer = SelectRandomPlayer();
SetPlayerHealth(randomplayer, 100);
You can make the code efficent tho.
Or you can use foreach include, for more efficent random player selecting.
Reply


Messages In This Thread
Random? - by dorotej - 06.06.2011, 12:44
Re: Random? - by WooTFTW - 06.06.2011, 13:01
Re: Random? - by dorotej - 06.06.2011, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)