10.03.2015, 22:03
I made this function along time ago once i began scripting. Its just to give you an idea, you can use it anyways (not tested).
Код:
stock fxnX() { new humans, zombies, total ; foreach (new i : Player) { switch (gTeam[i]) { case TEAM_HUMAN: humans++; case TEAM_ZOMBIE: zombies++; } total++; } if (humans < zombies) { //more zombies new humancount = floatround((total/2), floatround_floor) + 1/*Humans will always have 1 extra player*/, zombiecount = total - humancount ; foreach (new i : Player) { if (humancount > 0) //humans can still get a member? { gTeam[i] = TEAM_HUMAN; //set that guy humancount--; //decrease the var continue; //skip that loop to avoid continuation } if (zombiecount > 0) //zombies can count? { gTeam[i] = TEAM_ZOMBIE; //set as zombie zombiecount--; //count decrease } } } else SendClientMessageToAll(-1, "Teams are balanced") return 1; }