SA-MP Forums Archive
Randomizing every players team? - 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: Randomizing every players team? (/showthread.php?tid=392467)



Randomizing players for teams - persious - 14.11.2012

How the hell would I do that? I'm new to pawno, and I am sorry for such a simple question (At least it sounds so)


Re: Randomizing every players team? - [HK]Ryder[AN] - 14.11.2012

can you explain what do you want..i didn't understand it correctly

Although, you can use the Random() function


Re: Randomizing every players team? - persious - 14.11.2012

Well, I want to get every single player to randomize to eighter the team Murderer, but if there already is one murderer, the rest will go to the team SWAT.


Re: Randomizing every players team? - persious - 14.11.2012

I'll try and explain it a bit better.

So, what I want to do, is simply have all the players check if someone is on the team "Murderer", if not, it'll pick one of the players, and the rest will go onto the SWAT team. This will happen every time I call StartRound(playerid)


Re: Randomizing every players team? - ReneG - 14.11.2012

So you only want one person on the murder team?


Re: Randomizing every players team? - NumbSkull - 14.11.2012

you can foreach player get if they are murderer or swat and place new player on the team with less or just a simple switch if a var ...lets say the var is "team"== 1 set player murderer and "team" =2 and if "team" == 2 set swat and "team"= 1


Re: Randomizing every players team? - persious - 14.11.2012

Aha, I will try that.


Re: Randomizing every players team? - persious - 14.11.2012

Well, the thing is, that every player has to be forced to switch team, and if I did a if check, wouldn't it check the person who has the best connection first?


Re: Randomizing every players team? - persious - 14.11.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
So you only want one person on the murder team?
Yeah, exactly


Re: Randomizing every players team? - ReneG - 14.11.2012

Download and install foreach. Iter_Random(Player) selects a random connected player.
pawn Код:
new g_Murderer; // variable to hold the murderer's playerid

startRound()
{
    g_Murderer = Iter_Random(Player); // selects a random CONNECTED player
   
    SendClientMessage(g_Murderer, -1, "You are the murderer!");
   
    foreach(Player, i) // loops through all the connected players
    {
        if(i != g_Murderer) // if the player is not the murderer
        {
            // then the player is on the SWAT team.
            SendClientMessage(playerid, -1, "You are in the SWAT team!");
        }
    }
    return 1;
}