Skocz do zawartości

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

 Udostępnij


raven

Rekomendowane odpowiedzi

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;
}

 

  • WOW MEGA! 1
  • Haha! 1
Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Polityka prywatności