ArenaSkillaArchiwum forum

Zamknięty[Rozwiązane] Błąd ze zbyt dużą ilością osób w drużynie

Przez raven, 25 cze 2019, 17:21· 3 odpowiedzi · 1235 wyświetleń

Często po wymieszaniu drużyn na serwerze dzieje się tak, że przez 1-2 rundy gra się 6 v 4, nie wiem czy jesteście to w stanie naprawić, ale dobrze by było. :EZ: :Clap: 

FBlMcBb.jpg

NBcpwtm.jpg

 @ xBonio:EZ: 

Powierdzam :v

ok, znajdź mi gdzie tu jest błąd jak taki kozak

BalanceTeams()
{
	//Balance Team if not Balanced
	new terrorCount = RoundToFloor(GetClientCountFix(false) / 2.0);
	if(terrorCount > 5)
		terrorCount = 5;
	if(terrorCount < GetNextTeamCount(2, true))
	{
		new DamageList[MaxClients];
		new IndexList[MaxClients];
		new count = 0;
		for (new i = 1; i <= MaxClients; i++)
		{
			if(IsClientInGame(i) && GetClientTeam(i) == 2)
			{
				DamageList[count] = GetClientFrags(i);
				IndexList[count] = i;
				count++;
			}
		}
		new temp;
		new temp2;
		for (new i = 0; i < count; i++)
		{
			for (new j = i+1; j < count; j++)
			{
				if(DamageList[i] < DamageList[j])
				{
					temp = DamageList[i];
					temp2 = IndexList[i];
					DamageList[i] = DamageList[j];
					IndexList[i] = IndexList[j];
					DamageList[j] = temp;
					IndexList[j] = temp2;
				}
			}
		}
		for (new i = 0; i < GetNextTeamCount(2, true) - terrorCount; i++)
		{
			gi_NextRoundTeam[IndexList[i]] = 3;
		}
	}
	else if(terrorCount > GetNextTeamCount(2, true))
	{
		new DamageList[MaxClients];
		new IndexList[MaxClients];
		new count = 0;
		for (new i = 1; i <= MaxClients; i++)
		{
			if(IsClientInGame(i) && GetClientTeam(i) == 3)
			{
				DamageList[count] = GetClientFrags(i);
				IndexList[count] = i;
				count++;
			}
		}
		new temp;
		new temp2;
		for (new i = 0; i < count; i++)
		{
			for (new j = i+1; j < count; j++)
			{
				if(DamageList[i] > DamageList[j])
				{
					temp = DamageList[i];
					temp2 = IndexList[i];
					DamageList[i] = DamageList[j];
					IndexList[i] = IndexList[j];
					DamageList[j] = temp;
					IndexList[j] = temp2;
				}
			}
		}
		for (new i = 0; i < terrorCount - GetNextTeamCount(2, true); i++)
		{
			gi_NextRoundTeam[IndexList[i]] = 2;
		}
	}
}
ScrambleTeams(bool:includespec)
{
	PrintToChatAll("%sMieszanie drużyn.", PREFIX);
	new terrorCount = RoundToFloor(GetClientCountFix(includespec) / 2.0);
	if(terrorCount > 5)
		terrorCount = 5;
	new randomPlayer = -1;
	for (new i = 0; i < MAXPLAYERS; i++)
	{
		gi_NextRoundTeam[i] = -1;
	}
	for (new i = 0; i < terrorCount; i++)
	{
		randomPlayer = GetRandomPlayer(includespec);
		if(randomPlayer != -1)
		{
			gi_NextRoundTeam[randomPlayer] = 2;
			if(GetClientTeam(randomPlayer) == 1)
			{
				DeletePlayerFromQueue(i);
			}
		}
	}
	new ctCount = GetClientCountFix(true) - terrorCount;
	if(ctCount > 5)
		ctCount = 5;
	for (int i = 0; i < ctCount; i++)
	{
		randomPlayer = GetRandomPlayer(includespec);
		if(randomPlayer != -1)
		{
			gi_NextRoundTeam[randomPlayer] = 3;
			if(GetClientTeam(randomPlayer) == 1)
			{
				DeletePlayerFromQueue(i);
			}
		}
	}
	for (int i = 1; i <= MaxClients; i++)
	{
		if(IsClientInGame(i) && gi_NextRoundTeam[i] == -1)
		{
			gi_NextRoundTeam[i] = 1;
			AddPlayerToQueue(i);
		}
	}
	gb_balancedTeams = true;
}

Czyli zostaje jak jest. vtklJCz.png

Sprawa została wyjaśniona.