SA-MP Forums Archive
display the current amount of players (peer team) - 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: display the current amount of players (peer team) (/showthread.php?tid=229872)



display the current amount of players (peer team) - Amine_Mejrhirrou - 22.02.2011

hi all
can some one give me an example of how to display the current amount of players in a team pls
tnks


Re: display the current amount of players (peer team) - maramizo - 22.02.2011

I need the name of the team (something like gTeam_something) and the command you want.


Re: display the current amount of players (peer team) - 77ther - 22.02.2011

something like this?
pawn Код:
if(strcmp(cmd,"/members",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            new teamnumber;
            if (PlayerInfo[playerid][pLeader] != 0) teamnumber = PlayerInfo[playerid][pLeader];
            else if (PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You're not part of the team!");
                return 1;
            }
            SendClientMessage(playerid, 0x808000AA, "**Team Members Online**");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if (IsPlayerConnected(i))
                {
                    GetPlayerName(i, sendername, sizeof(sendername));
                    format(string, sizeof(string), "");
                    if (PlayerInfo[i][pLeader] == teamnumber) format(string, sizeof(string), "%s (LIDER)",sendername);
                    else if (PlayerInfo[i][pMember] == teamnumber) format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);
                    if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);
                }
            }
        }
        return 1;
    }



Re : Re: display the current amount of players (peer team) - Amine_Mejrhirrou - 22.02.2011

Quote:
Originally Posted by maramizo
Посмотреть сообщение
I need the name of the team (something like gTeam_something) and the command you want.
static team[MAX_PLAYERS];
static infected[MAX_PLAYERS];

i have team 1
i have team 2
i have team 4
i have team 5
i have team 6


Re: display the current amount of players (peer team) - maramizo - 22.02.2011

Quote:
Originally Posted by 77ther
Посмотреть сообщение
something like this?
pawn Код:
if(strcmp(cmd,"/members",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            new teamnumber;
            if (PlayerInfo[playerid][pLeader] != 0) teamnumber = PlayerInfo[playerid][pLeader];
            else if (PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You're not part of the team!");
                return 1;
            }
            SendClientMessage(playerid, 0x808000AA, "**Team Members Online**");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if (IsPlayerConnected(i))
                {
                    GetPlayerName(i, sendername, sizeof(sendername));
                    format(string, sizeof(string), "");
                    if (PlayerInfo[i][pLeader] == teamnumber) format(string, sizeof(string), "%s (LIDER)",sendername);
                    else if (PlayerInfo[i][pMember] == teamnumber) format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);
                    if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);
                }
            }
        }
        return 1;
    }
Use ZCMD and SSCANF, way faster.
@OP I'm making it.


Re: display the current amount of players (peer team) - maramizo - 22.02.2011

Should be something like
pawn Код:
CMD:infectedon(playerid, params[])
{
    new numberon = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerConnected(i) && infected[i])
    {
        numberon++;
    }
    if(numberon > 1)
    {
        new string[128];
        format(string,sizeof(string),"There are %i infected players.", numberon);
        SendClientMessage(playerid, 0xFFFFFFF, string);
        return 1;
    }
    if(numberon == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFF, "There are no infected players online");
        return 1;
    }
}



Re : display the current amount of players (peer team) - Amine_Mejrhirrou - 22.02.2011

thnks ! i'm gonna use this in a textdraw to show the curent number of "zombies" in the server


Re: display the current amount of players (peer team) - maramizo - 22.02.2011

Okay tell me if it worked.


Re : display the current amount of players (peer team) - Amine_Mejrhirrou - 24.02.2011

it wont work
i try to show the curent number in a team by a textdraw but i dosen't work
hhhelllpp


Re : display the current amount of players (peer team) - Amine_Mejrhirrou - 24.02.2011

This is my code
Quote:

forward infectedtimer();

Quote:

public OnGameModeInit()
{
SetTimer("infectedtimer", 5000, 1);
}

Quote:

public infectedtimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new numberon = 0;
if(IsPlayerConnected(i) && team[i] == 2)
{
numberon++;
new string[128];
format(string,sizeof(string),"Zombies %i ", numberon);
LOLL = TextDrawCreate(2.000000,240.000000, string);
TextDrawFont(LOLL, 3);
TextDrawColor(LOLL,0xAA33338;
TextDrawLetterSize(LOLL, 0.439999, 1.400000);
TextDrawShowForPlayer(i, LOLL);

}
}
}

whйn i'm playing (as a zombie or human ) the texdraw doesn't apear