SA-MP Forums Archive
Random Team For 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 Team For player (/showthread.php?tid=652449)



Random Team For player - UFF - 11.04.2018

Hello, i am wondering how to make random team for players.

Код:
#define Ranger 1
#define Mafia 2

     foreach(Player, ii)
    {
	if(GetPlayerTeam(ii) == 1) ++Ranger;
	else if(GetPlayerTeam(ii) == 2) ++Mafia;
	SetPlayerTeam(ii, (Ranger > Mafia)+1);
   }
Error
Код:
test.pwn(551) : error 022: must be lvalue (non-constant)
test.pwn(552) : error 022: must be lvalue (non-constant)
test.pwn(553) : warning 213: tag mismatch
test.pwn(597) : error 022: must be lvalue (non-constant)
test.pwn(598) : error 022: must be lvalue (non-constant)
test.pwn(599) : warning 213: tag mismatch
i don't really know how to make random team for players.. This is a Tdm script and i want players to spawn in random 2 teams. Can anyone help me in making random teams?

+rep, Thanks in Advance!


Re: Random Team For player - Renisal - 11.04.2018

Uhmm like this? (replace)

Код:
new Mafia, Ranger;
foreach(Player, i) 
{
    if(GetPlayerTeam(i) == 1) ++Mafia;
    else if(GetPlayerTeam(i) == 2) ++Ranger;
}
SetPlayerTeam(playerid, (Mafia> Ranger)+1); // This will be either 1 or 2



Re: Random Team For player - Wanheda - 11.04.2018

Код:
new teamCount[2], teamid;
foreach(Player, ii)
{
	teamid = random(2);
	SetPlayerTeam(ii, teamid);
	teamCount[teamid] ++;
}
This is what you should relay on. Basically loop through all players and set them to a random team (teamid 0 or 1).