SA-MP Forums Archive
Random person? - 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 person? (/showthread.php?tid=152218)



Random person? - w00tNew - 03.06.2010

im confused on making every round gm starts how would i make it choose a random person to go to TEAM_0 my define<< i made one but was buggy and picking same person at a time-.-


Re: Random person? - w00tNew - 03.06.2010

bump


Re: Random person? - Backwardsman97 - 03.06.2010

I wasn't sure what you meant so I made two functions.

http://pastebin.com/6VW51AH3


Re: Random person? - w00tNew - 03.06.2010

i mean like onplayerspawn if gives u a timer of 40 sec which i already have but i want it to choose a random player from TEAM_0 to become one of them vs the other team


Re: Random person? - Backwardsman97 - 03.06.2010

pawn Код:
new
    Players[MAX_PLAYERS],
    count;

for(new i; i<MAX_PLAYERS; i++)
{
  if(IsPlayerConnected(i))
  {
    if(GetPlayerTeam(i) == TEAM_0)
    {
      Players[count] = i;
      count++;
    }
  }
}
new rand = sizeof(Players);
//Players[rand] would be the random player
That will generate a random player off of TEAM_0.