Random Team For player
#1

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!
Reply
#2

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
Reply
#3

Код:
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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)