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;
}