[HELP] View all team-members online
#1

Can you check this command for me. The issue I have is when two players is online and in a different team I can stil lsee him or her in the command.

pawn Код:
if(strcmp(cmd, "/faction", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "   You are not logged in yet.");
                return 1;
            }
            if(PlayerInfo[playerid][pTeam] == 2)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 12) { format(string, sizeof(string), "   Chief of Police %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 11) { format(string, sizeof(string), "  Deputy Chief %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "  Commander %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Captain %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   CIT Staff Sergeant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Staff Sergeant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Senior Lead Officer %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Lead Officer %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Police Officer II %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Police Officer I %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 3)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "   Sheriff %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Undersheriff %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Assistant Sheriff %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Captain %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Corporal %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Deputy Sheriff II %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Deputy Sheriff I %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Deputy Sheriff Generalist %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 4)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "   Commissioner %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Bureau Chief %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Battalion Chief %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Attending Physician %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Medical Student %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Engineer %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Firefighter II %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Firefighter I %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Probationary Firefighter %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 5)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "    Mayor %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Deputy Mayor %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Council Member %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Director %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Public Defender %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Protection Agent %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Secretary %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Lawyer %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Associate %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 6)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "    Executive Director %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   General Director %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Network Executive %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Network Anchor %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Reporter %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Media Student %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 7)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "    Commissioner %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Deputy Commissioner %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Assistant Commissioner %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Captain %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                        else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Trooper %s", sendername); }
                        SendClientMessage(playerid, COLOR_DARKGREY, string);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "   You are not authorized to use that command.");
            }
        }
        return 1;
    }
Reply
#2

if(strcmp(cmd,"/faction",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 are not in any faction!");
return 1;
}
SendClientMessage(playerid, 0x808000AA, "**Membre 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 (LEADER)",sendername);
else if (PlayerInfo[i][pMember] == teamnumber) format(string, sizeof(string), "%s, Rang: %d.",sendername, PlayerInfo[i][pRank]);
if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);
}
}
}
return 1;
}

try to make some copy
Reply
#3

Quote:
Originally Posted by BigBaws
Посмотреть сообщение
if(strcmp(cmd,"/faction",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 are not in any faction!");
return 1;
}
SendClientMessage(playerid, 0x808000AA, "**Membre 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 (LEADER)",sendername);
else if (PlayerInfo[i][pMember] == teamnumber) format(string, sizeof(string), "%s, Rang: %d.",sendername, PlayerInfo[i][pRank]);
if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);
}
}
}
return 1;
}

try to make some copy
Try to use [pawn] when posting PAWN codes. Anyway, that didn't work out.
Reply
#4

Try this:
pawn Код:
if(strcmp(cmd, "/faction", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "   You are not logged in yet.");
                return 1;
            }
            if(PlayerInfo[playerid][pTeam] == 2)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 12) { format(string, sizeof(string), "   Chief of Police %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 11) { format(string, sizeof(string), "  Deputy Chief %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "  Commander %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Captain %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   CIT Staff Sergeant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Staff Sergeant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Senior Lead Officer %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Lead Officer %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Police Officer II %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Police Officer I %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 3)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "   Sheriff %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Undersheriff %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Assistant Sheriff %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Captain %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Corporal %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Deputy Sheriff II %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Deputy Sheriff I %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Deputy Sheriff Generalist %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 4)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 10) { format(string, sizeof(string), "   Commissioner %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "   Bureau Chief %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Battalion Chief %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Attending Physician %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Medical Student %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Engineer %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Firefighter II %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Firefighter I %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Probationary Firefighter %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 5)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 9) { format(string, sizeof(string), "    Mayor %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 8) { format(string, sizeof(string), "   Deputy Mayor %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "   Council Member %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Director %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Public Defender %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Protection Agent %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Secretary %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Lawyer %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Associate %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 6)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "    Executive Director %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   General Director %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Network Executive %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Network Anchor %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Reporter %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Media Student %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else if(PlayerInfo[playerid][pTeam] == 7)
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "Members Online:");
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
                        {
                            GetPlayerName(i, sendername, sizeof(sendername));
                            if(PlayerInfo[i][pRank] == 7) { format(string, sizeof(string), "    Commissioner %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 6) { format(string, sizeof(string), "   Deputy Commissioner %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 5) { format(string, sizeof(string), "   Assistant Commissioner %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 4) { format(string, sizeof(string), "   Captain %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 3) { format(string, sizeof(string), "   Lieutenant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 2) { format(string, sizeof(string), "   Sergeant %s", sendername); }
                            else if(PlayerInfo[i][pRank] == 1) { format(string, sizeof(string), "   Trooper %s", sendername); }
                            SendClientMessage(playerid, COLOR_DARKGREY, string);
                        }
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_DARKGREY, "   You are not authorized to use that command.");
            }
        }
        return 1;
    }
this should be fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)