Team Players
#1

Hi, I was wondering if there was a way of getting the total amount of players on each team?

Like when I start the round, we can play a TDM and then the round will end.

pawn Код:
if (gTeam[playerid] == TEAM_HOME)
    {
        SetPlayerColor(playerid, TEAM_HOME_COLOR);
        SetPlayerTeam(playerid, 1);
        bluecount++;
        if(First[playerid] == 1)
        {
            format(string, sizeof(string), "** %s has spawned as the team HOME.", pname);
            SendClientMessageToAll(TEAM_HOME_COLOR, string);
        }
    }
    else
    {
        SetPlayerColor(playerid, TEAM_AWAY_COLOR);
        SetPlayerTeam(playerid, 2);
        redcount++;
        if(First[playerid] == 1)
        {
            format(string, sizeof(string), "** %s has spawned as the team AWAY.", pname);
            SendClientMessageToAll(TEAM_AWAY_COLOR, string);
        }
    }
IS THERE ANYWAY I CAN GET THE TOTAL COUNT OF EACH TEAM?
Reply
#2

pawn Код:
stock GetTeamCount(teamid)
{
    if(teamid == TEAM_HOME)
        return bluecount;
       
    if(teamid == TEAM_AWAY) // that's your second team id huh?
        return redcount;
       
    return -1; // returns -1 if the team is not defined (In the stock)
}
Reply
#3

How do I use that as a stock?
Reply
#4

pawn Код:
// Usage: GetTeamCount(teamid);
// Example:
printf("The home team count is %d", GetTeamCount(TEAM_HOME));
Reply
#5

Using foreach inc.
pawn Код:
stock GetTeamPlayers()
{
    new blueteam, redteam;
    foreach(Player, i)
    {
        if(GetPlayerTeam(i) == 1)
        {
            blueteam++
        }
        if(GetPlayerTeam(i) == 2)
        {
            redteam++
        }
    }
    new str[128];
    format(str, 128, "Red team has %i players, while blue team has %i players.", redteam, blueteam);
    return str;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)