If team is full --> Switch team
#1

How can you make like, if one of the team is full, 1/2 automaticly go to the other one, so it are both even teams? (If you choose class and just in-game)
Reply
#2

Try this

Код:
public OnPlayerRequestSpawn(playerid)
{
	new count1,count2;
	for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(pi[playerid][army] == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM)
    else if (pi[playerid][Terr] == 1) count2 ++; // Same for here, just the other team
  }
  	if(count1 > count2)
  {
		GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
		ForceClassSelection(playerid);
	}
	else if(count2 > count1)
	{
	  GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
		ForceClassSelection(playerid);
	}
 	return 1;
}
It's untested, but i belive it works

-Naxix
Reply
#3

Quote:
Originally Posted by Naxix
Try this

Код:
public OnPlayerRequestSpawn(playerid)
{
	new count1,count2;
	for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(pi[playerid][army] == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM)
    else if (pi[playerid][Terr] == 1) count2 ++; // Same for here, just the other team
  }
 	if(count1 > count2)
  {
		GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
		ForceClassSelection(playerid);
	}
	else if(count2 > count1)
	{
	  GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
		ForceClassSelection(playerid);
	}
 	return 1;
}
It's untested, but i belive it works

-Naxix
Sorry, I don't understand the pi[playerid][army] == 1.

I have a team called Zombie, and a team called Human. So, how do you make :S?
Reply
#4

Do you use gTeam or how you made your teams?
Reply
#5

Quote:
Originally Posted by Naxix
Do you use gTeam or how you made your teams?
Oh.. I have it, but now errors:

Quote:

C:\Users\Robin\humanvszombies\zm.pwn(279) : error 076: syntax error in the expression, or invalid function call
C:\Users\Robin\humanvszombies\zm.pwn(280) : error 076: syntax error in the expression, or invalid function call

Quote:

if(PlayerTeam == ZombieTeam == 1) count1 ++; // Change "pi[playerid][army] == 1) " to like if(gTeam == TEAM)
else if (PlayerTeam == HumanTeam == 1) count2 ++; // Same for here, just the other team

E/ If I delete == 1 I get the same error.
Reply
#6

Use:

Код:
    if(PlayerTeam == ZombieTeam) count1 ++;
    else if (PlayerTeam == HumanTeam) count2 ++;
Reply
#7

Quote:
Originally Posted by Naxix
Use:

Код:
    if(PlayerTeam == ZombieTeam) count1 ++;
    else if (PlayerTeam == HumanTeam) count2 ++;
same error.
Reply
#8

Try

Код:
    if(PlayerTeam(playerid) == ZombieTeam) count1 ++;
    else if (PlayerTeam(playerid) == HumanTeam) count2 ++;
Reply
#9

Quote:
Originally Posted by Naxix
Try

Код:
    if(PlayerTeam(playerid) == ZombieTeam) count1 ++;
    else if (PlayerTeam(playerid) == HumanTeam) count2 ++;
Quote:

C:\Users\Robin\humanvszombies\zm.pwn(277) : error 012: invalid function call, not a valid address
C:\Users\Robin\humanvszombies\zm.pwn(277) : warning 215: expression has no effect
C:\Users\Robin\humanvszombies\zm.pwn(277) : error 001: expected token: ";", but found ")"
C:\Users\Robin\humanvszombies\zm.pwn(277) : error 029: invalid expression, assumed zero
C:\Users\Robin\humanvszombies\zm.pwn(277) : fatal error 107: too many error messages on one line

Reply
#10

Код:
    if(PlayerTeam[playerid] == ZombieTeam) count1 ++;
    else if (PlayerTeam[playerid] == HumanTeam) count2 ++;
Reply
#11

Quote:
Originally Posted by Naxix
Код:
    if(PlayerTeam[playerid] == ZombieTeam) count1 ++;
    else if (PlayerTeam[playerid] == HumanTeam) count2 ++;
:S wtf is thiz shit:

Quote:

C:\Users\Robin\humanvszombies\zm.pwn(277) : error 076: syntax error in the expression, or invalid function call
C:\Users\Robin\humanvszombies\zm.pwn(27 : error 076: syntax error in the expression, or invalid function call

same error as before :/

E/ I got it. I switched Human Team and Zombie Team to 1 and 0 .
Reply
#12

Try this script:

Код:
public OnPlayerRequestSpawn(playerid)
{
	new count1,count2;
	for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(PlayerTeam[i] == ZombieTeam)
		{
			count1 ++;
		}
    else if (PlayerTeam[i] == HumanTeam)
		{
			count2 ++; // Same for here, just the other team
		}
  			if(count1 > count2)
  		{
				GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
				ForceClassSelection(playerid);
			}
			else if(count2 > count1)
			{
	  		GameTextForPlayer(playerid,"~r~This team is full! Please select another.",3000,3);
				ForceClassSelection(playerid);
			}
		}
	}
 	return 1;
}
Might be some lose brackets, i made it here.
Reply
#13

I done it with the other one..

I tested it, but even when there are 0 players, it tells me to change team ... I didn't even chose something, just automaticly go
Reply
#14

Try this then..

Код:
  new Count1, Count2;
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(PlayerTeam[playerid] == ZombieTeam) Count1++;
    else if (PlayerTeam[playerid] == HumanTeam) Count2++;
  }
  if ((Count1 > Count2) && PlayerTeam[playerid] == HumanTeam)
  {
    SendClientMessage(playerid,COLOUR_RED, "Balancing teams. Choose Another Team");
    return 0;
  }
  else if ((Count2 > Count1) && PlayerTeam[playerid] == ZombieTeam)
  {
    SendClientMessage(playerid,COLOUR_RED, "[BALANCER] Balancing teams. Choose Another Team");
    return 0;
  }
  return 1;
	}
Reply
#15

Quote:
Originally Posted by Naxix
Try this then..

Код:
  new Count1, Count2;
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(PlayerTeam[playerid] == ZombieTeam) Count1++;
    else if (PlayerTeam[playerid] == HumanTeam) Count2++;
  }
  if ((Count1 > Count2) && PlayerTeam[playerid] == HumanTeam)
  {
    SendClientMessage(playerid,COLOUR_RED, "Balancing teams. Choose Another Team");
    return 0;
  }
  else if ((Count2 > Count1) && PlayerTeam[playerid] == ZombieTeam)
  {
    SendClientMessage(playerid,COLOUR_RED, "[BALANCER] Balancing teams. Choose Another Team");
    return 0;
  }
  return 1;
	}
This doesn't work for not spawning, right? :P
Reply
#16

It should prevent players from spawning.
Reply
#17

Quote:
Originally Posted by Naxix
It should prevent players from spawning.
Hmm.. Not working for me :/.

Btw, I want that like it balances the team .. Too if your already playing

E/: Whole OnPlayerRequestClass:

Quote:

public OnPlayerRequestClass(playerid,classid)
{

new Count1, Count2;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerTeam[playerid] == 0) Count1++;
else if (PlayerTeam[playerid] == 1) Count2++;
}
if ((Count1 > Count2) && PlayerTeam[playerid] == 1)
{
SendClientMessage(playerid,COLOR_RED, "Balancing teams. Choose Another Team");
return 0;
}
else if ((Count2 > Count1) && PlayerTeam[playerid] == 0)
{
SendClientMessage(playerid,COLOR_RED, "[BALANCER] Balancing teams. Choose Another Team");
return 0;
}

SetPlayerPos(playerid,299.9177,2741.7598,42.9127);
SetPlayerFacingAngle(playerid,198.9686);
SetPlayerCameraPos(playerid,306.3498,2727.6697,37. 0493);
SetPlayerCameraLookAt(playerid,299.9177,2741.7598, 42.9127);
if(classid == 0)
{
PlayerTeam[playerid] = 0;
SetPlayerTeam(playerid,0);
}
else if(classid == 1)
{
PlayerTeam[playerid] = 1;
SetPlayerTeam(playerid,1);
}

return 1;
}

Reply
#18

You cut be useing a timer to make it balance it while playing.
Reply
#19

Naxix, do I need the whole thing to? I mean, should I use your script for the whole onplayerrequestclass, or the other things like

Quote:

if(classid == 0)
{
PlayerTeam[playerid] = 0;
SetPlayerTeam(playerid,0);
}
else if(classid == 1)
{
PlayerTeam[playerid] = 1;
SetPlayerTeam(playerid,1);
}

should be there too?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)