How to get the count of players?
#2

This uses foreach, if you don't have it already, download it! It returns the gang the players are in.
pawn Код:
#define MAX_GANGS 9

new bool:pGangs[MAX_PLAYERS][MAX_GANGS];

CMD:gangs(playerid, cmd[], cmdtext[])
{
    foreach(new i: Player)
    {
        for(new g = 0; g < MAX_GANGS; g ++)
        {
            if(pGangs[i][g] == true)
            {
                format(string, sizeof(string), "Gang %d: %s (%d)", g, PlayerName(i), i);
                SendClientMessage(playerid, -1, string);
            }
        }
    }
    return 1;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}
This returns the players in a specific gang!
pawn Код:
#define MAX_GANGS 2

new bool:pGangs[MAX_PLAYERS][MAX_GANGS];

CMD:grove(playerid, cmd[], cmdtext[])
{
    foreach(new i: Player)
    {
        if(pGangs[i][0] == true)
        {
            format(string, sizeof(string), "Gang %d: %s (%d)", 0, PlayerName(i), i);
            SendClientMessage(playerid, -1, string);
        }
    }
    return 1;
}

CMD:ballas(playerid, cmd[], cmdtext[])
{
    foreach(new i: Player)
    {
        if(pGangs[i][1] == true)
        {
            format(string, sizeof(string), "Gang %d: %s (%d)", 1, PlayerName(i), i);
            SendClientMessage(playerid, -1, string);
        }
    }
    return 1;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}
This uses sscanf, download it if you don't have it! This returns the members in a gang defined by the user!
pawn Код:
#define MAX_GANGS 2

new bool:pGangs[MAX_PLAYERS][MAX_GANGS];

CMD:gangmembers(playerid, cmd[], cmdtext[])
{
    new gangid;
    if(sscanf(cmdtext, "i", gangid)) return SendClientMessage(playerid, -1, "Usage: /gangmembers (gang id).");
    if(gangid < 0 || gangid > MAX_GANGS) return SendClientMessage(playerid, -1, "You have entered an invalid gang id.");
    foreach(new i: Player)
    {
        if(pGangs[i][gangid] == true)
        {
            format(string, sizeof(string), "Gang %d: %s (%d)", gangid, PlayerName(i), i);
            SendClientMessage(playerid, -1, string);
        }
    }
    return 1;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}
Reply


Messages In This Thread
How to get the count of players? - by Axey187 - 08.01.2015, 00:58
Re: How to get the count of players? - by SickAttack - 08.01.2015, 01:15
Re: How to get the count of players? - by Axey187 - 08.01.2015, 01:19
Re: How to get the count of players? - by Axey187 - 08.01.2015, 13:32
Re: How to get the count of players? - by danish007 - 08.01.2015, 13:41
Re: How to get the count of players? - by Axey187 - 08.01.2015, 13:50
Re: How to get the count of players? - by Axey187 - 08.01.2015, 13:52
Re: How to get the count of players? - by Sawalha - 08.01.2015, 13:54
Re: How to get the count of players? - by danish007 - 08.01.2015, 13:54
Re: How to get the count of players? - by Axey187 - 08.01.2015, 14:14

Forum Jump:


Users browsing this thread: 1 Guest(s)