SA-MP Forums Archive
Team Balance - 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: Team Balance (/showthread.php?tid=574206)



Team Balance - Blackazur - 14.05.2015

Hello how to make this team balance random without that it is chosing after ID's?

Код:
stock TeamBalance()
{
	new Humans;
	foreach(Player, i)
	{
	    if(Humans < 3)
	    {
	        HumanSetup(i);
	        printf("Selected humans");
	        Humans ++;
	    }
	    else
	    {
	        ZombieSetup2(i);
	        printf("Selected zombies");
	        Humans = 0;
	    }
	}
	printf("Finished Selecting teams");
	return 1;
}



Re: Team Balance - Gammix - 15.05.2015

foreach or y_iterrate have a random feature, use it.

pawn Код:
Iter_Random(Player); //for players but if you have your own iter., than you can specify that instead of Player
And i completely recommend you to create your own iterrate for team humans!

pawn Код:
stock TeamBalance()
{
    new Humans;
    foreach(Player, i)
    {
        if(Humans < 3)
        {
            HumanSetup(i);
            printf("Selected humans");
            Humans ++;
        }
        else
        {
            new randomzombie = Iter_Random(Player);
            if(GetPlayerTeam(i) == TEAM_HUMANS)
            {
                ZombieSetup2(randomzombie);
                printf("Selected zombies");
                Humans = 0;
            }
            else //make this timer run again or if its already dependent on "Humans=0", than ignore.
        }
    }
    printf("Finished Selecting teams");
    return 1;
}