Random?
#1

someone know how to select a random player?
Reply
#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
#3

thanks for help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)