SA-MP Forums Archive
Player Count - 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: Player Count (/showthread.php?tid=381281)



Player Count - (_AcE_) - 29.09.2012

How do I get the script to identify how many players are in team blue and in team red? How can I get the server to detect how many players are in each team so when I play who ever has no more players left they lose?

pawn Код:
dcmd_add(playerid, params[])
{
    if(isclanwarstarted == 1)
    {
        if(sscanf(params, "u", params[0]))
        {
            if(gTeam[params[0]] == TEAM_HOME || gTeam[params[0]] == TEAM_AWAY)
            {
                iDM[params[0]] = 0;
                First[params[0]] = 0;
                ResetPlayerWeapons(params[0]);
                SetPlayerInterior(params[0], 10);
                GivePlayerWeapon(params[0], 31, 9999);
                GivePlayerWeapon(params[0], 27, 9999);
                GivePlayerWeapon(params[0], 24, 9999);
                SetPlayerHealth(params[0], 100);
                SetPlayerArmour(params[0], 100);
                TogglePlayerControllable(params[0],0);
                if(gTeam[params[0]] == TEAM_HOME)
                {
                    SetPlayerPos(params[0], -1131.9910,1057.6470,1346.4126);
                    SetPlayerFacingAngle(params[0], 270);
                    bluecount++;
                    FormMessageForAll(playerid,COLOR_MESSAGE, "** An Administrator has added %s to the current round!", PlayerName2(params[0]);
                }
                else if(gTeam[params[0]] == TEAM_AWAY)
                {
                    SetPlayerPos(params[0], -973.9210,1061.2968,1345.6729);
                    SetPlayerFacingAngle(params[0], 90);
                    redcount++;
                    FormMessageForAll(playerid,COLOR_MESSAGE, "** An Administrator has added %s to the current round!", PlayerName2(params[0]);
                }
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: There is currently an inactive round!");
        PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
    }
    return 1;
}
That is an example. Whenever they spawn on blue team i do : bluecount++ and red team redcount++;


Re: Player Count - Glint - 29.09.2012

You need to loop through all player's -> check their team -> increment a variable accordingly.


Re: Player Count - (_AcE_) - 30.09.2012

Ok, thanks for trying to increase your post count..

Any help? That is the main reason why I posted here, I don't know how..


AW: Player Count - Nero_3D - 30.09.2012

Decrease the team size for each team in OnPlayerDeath, something like that
pawn Код:
// OnPlayerDeath
    if(gTeam[playerid] == TEAM_HOME) {
        if(--bluecount == 0) { // using an array here would be way better
            SendClientMessage(playerid, -1, "Red won!");
            // other code to end the clan war
        }
    } else if(gTeam[playerid] = TEAM_AWAY) { // if their are only these two teams you could use else
        if(--redcount == 0) {
            SendClientMessage(playerid, -1, "Blue won!");
            // other code to end the clan war
        }
    }