SA-MP Forums Archive
All == TEAM_HUMAN - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: All == TEAM_HUMAN (/showthread.php?tid=191721)



All == TEAM_HUMAN - Kitten - 20.11.2010

Solved


Re: All == TEAM_HUMAN - Lorenc_ - 20.11.2010

Start some playercounting on each team

pawn Код:
new zPlayers, hPlayers;
now, find the codes where when a person chooses that class there a zombie or human and add zPlayers++ on the zombies side and hPlayers++; on the humans side of code, then set a repeating timer to detect if there are no players in the team zombies and no players in the in the team humans... thats just the beginning although i really i dont think i can think about how to grab 3 random players from the zombie/human team. I hope i made sense D:


Re: All == TEAM_HUMAN - TheXIII - 20.11.2010

pawn Код:
new NonZombieCount;
#define MIN_NONZOMBIES 3
foreach( Player, i )
{
    if( PlayerTeam[i] != ZOMBIE_TEAM ) NonZombieCount++;
    if( NonZombieCount >= MIN_NONZOMBIES ) break;
}
if( NonZombieCount >= MIN_NONZOMBIES )
{
    new PlayersAssigned, pID;
    do{
        pID = Iter_Random(Player);
        if( PlayerTeam[pID] == ZOMBIE_TEAM )
        {
            PlayerTeam[pID] = HUMAN_TEAM;
            PlayersAssigned++;
        }
    }
    while( PlayersAssigned >= MIN_NONZOMBIES );
}
#undef MIN_NONZOMBIES
Something like that.

EDIT: Sorry, just woke. Gimme a sec.
EDIT2:
pawn Код:
new NonZombieCount;
foreach( Player, i )
{
    if( PlayerTeam[i] != ZOMBIE_TEAM ) NonZombieCount++;
}
if( !NonZombieCount )
{
    new PlayersAssigned, pID;
    do{
        pID = Iter_Random(Player);
        if( PlayerTeam[pID] == ZOMBIE_TEAM )
        {
            PlayerTeam[pID] = HUMAN_TEAM;
            PlayersAssigned++;
        }
    }
    while( PlayersAssigned >= MIN_NONZOMBIES );
}



Re: All == TEAM_HUMAN - Hiddos - 20.11.2010

Or just return 0 at OnPlayerRequest spawn when it appears that one team contains more players then the other, no need for stupido timers.


AW: All == TEAM_HUMAN - Saitecx - 20.11.2010

pawn Код:
forward Human(playerid);

SetTimer("Human", 2000,1);

public Human(playerid)
{
    if(gTeam[playerid] == TEAM_ZOMBIE)
{
// Register here if so many players in the team are to change it
gTeam[playerid] = TEAM_HUMAN;
return 1;
}
return 1;
}



Re: All == TEAM_HUMAN - TheXIII - 20.11.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Or just return 0 at OnPlayerRequest spawn when it appears that one team contains more players then the other, no need for stupido timers.
How does that put 3 players into human team, when all players are in zombie team?
Players don't need to respawn to become zombies. And he doesn't want them to not be able to spawn..
(maybe they do need to respawn, I don't know how the GM works, but still.)

No one has even mentioned any timers. The code I posted, which is really basicly the same as Lorenc_ suggested, can be put for example under function which makes players zombies. There is no need for timers. Although it can work with a timer. Even then, a 5 second timer is sufficent and nothing resource hungry.