SA-MP Forums Archive
Random 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)
+--- Thread: Random Player (/showthread.php?tid=352900)



Random Player - sanrock - 21.06.2012

ok i have a question ... how can i make a random player change team if all the players are in the same team !
i mean if all the player are in the same team : change a random player to an other team


Re: Random Player - ReneG - 21.06.2012

You can do this by using the Iter_Random function with foreach.
For example.
pawn Code:
randPlayer = Iter_Random(Player);
It will only select a random player that is connected. Make sure it says "Player". Player is the custom iterator in foreach for connected players.


Re: Random Player - MadeMan - 21.06.2012

https://sampforum.blast.hk/showthread.php?tid=318722
https://sampforum.blast.hk/showthread.php?tid=281692
https://sampforum.blast.hk/showthread.php?tid=261708
https://sampforum.blast.hk/showthread.php?tid=249450
https://sampforum.blast.hk/showthread.php?tid=269060
https://sampforum.blast.hk/showthread.php?tid=188307

Use search next time.


Re: Random Player - judothijs - 21.06.2012

pawn Code:
new randomsize = [MAX_PLAYERS];
new randomnumber = random(sizeof(randomsize));

for(new i = 0; i < [MAX_PLAYERS]);
{
       if( randomnumber == playerid(i))
       {
                // Your teamswitching code...
                return 1;
        }
        else
        {
            i++;
         }
         return 1;
}
Copy + paste might not work as I just wrote what came up to me, but the idea is simple.