SA-MP Forums Archive
Random choose player - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random choose player (/showthread.php?tid=152252)



Random choose player - Nonameman - 03.06.2010

Hello,

I'm making a script, which choose a random player every 5 minutes, and other players have to kill him for money.
The only thing i can't make in it is to choose the random playerid, and put this value into MarkedPlayer[MAX_PLAYERS].

Any ideas? :P


Re: Random choose player - iStarzz - 03.06.2010

pawn Код:
stock GetRandomPlayer()
{
  new yplayer[MAX_PLAYERS+1];
  for (new y = 0; y != MAX_PLAYERS; y ++) {
    if (IsPlayerConnected(y)) {
      yplayer[0] ++;
      yplayer[yplayer[0]] = y;
    }
  }
  return yplayer[random(yplayer[0])+1];
}



Re: Random choose player - Nonameman - 03.06.2010

thanks a lot


Re: Random choose player - iStarzz - 03.06.2010

No problem