12.05.2013, 10:51
Hey, need help with listing players in a class, example, every player in the police class can be listed by doing /policelist or something like that, if someone can help me with that, thanks
new AStr[MAX_PLAYER_NAME + 4],FStr[240];
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == POLICE)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
format(AStr, sizeof(AStr), "%s(%d)\n",name,i);
strcat(FStr, AStr, sizeof(FStr));
}
}
ShowPlayerDialog(playerid, 4684, DIALOG_STYLE_MSGBOX, "PoliceList", FStr, "Close", "");
for(new i ; i < MAX_PLAYERS ; i++ )
{
if(IsPlayerConnected( i ))
{
if( My_Enum[ i ][ pTeamOrClass ] == TEAM_POLICE )
{
printf("%d", i);
}
}
}
#define POLICE_CLASS 1 //Change the classid to yours.
new pTeam[MAX_PLAYERS];
public OnPlayerRequestClass(playerid, classid)
{
if(classid == POLICE_CLASS)
{
pTeam[playerid] = POLICE_CLASS;
}
return 1;
}
CMD:policelist(playerid, params[])
{
new str[30], Lname[MAX_PLAYER_NAME], str2[128];
SendClientMessage(playerid, 0xFF0000FF, "__________________________________________");
SendClientMessage(playerid, 0xFF0000FF, " Online Cops");
SendClientMessage(playerid, -1, "");
for(new i; i< GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(pTeam[i] == POLICE_CLASS)
{
GetPlayerName(i, Lname, sizeof(Lname));
format(str, sizeof(str), "%s (ID:%d)\n", Lname, i);
strcat(str2, str, sizeof(str2));
}
}
SendClientMessage(playerid, 0xFF0000, str2);
SendClientMessage(playerid, 0xFF0000FF, "_________________________________________");
return 1;
}