Members in family
#1

Well, on my RP server I have a command that is /members. Then all the members in your family should pop up, but instead it says like "Members Online
Austin: Rank 6
Austin: Rank 2
Austin: Rank 4"

So how to set so the player names instead of my name pops up?

Here is my code.

pawn Код:
CMD:members(playerid, params[])

{
    if(IsPlayerConnected(playerid))

    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new teamnumber;
        if (PlayerInfo[playerid][pLeader] != 0) teamnumber = PlayerInfo[playerid][pLeader];
        else if (PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
        else if (PlayerInfo[playerid][pFMember] != 255) teamnumber = PlayerInfo[playerid][pFMember];
        else

        {
            SendClientMessage(playerid, COLOR_GRAD1, "You are not a member of an organization!");
            return 1;

        }
        SendClientMessage(playerid, 0x808000AA, "Members Online:");
        for(new i = 0; i < MAX_PLAYERS; i++)

        {
            if (IsPlayerConnected(i))

            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "");
                if(PlayerInfo[playerid][pLeader] || PlayerInfo[playerid][pMember])

                {
                    if (PlayerInfo[i][pLeader] == teamnumber)

                    {
                        format(string, sizeof(string), "%s (Leader)",sendername);

                    }
                    else if (PlayerInfo[i][pMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                else if(PlayerInfo[playerid][pFMember] != 255)

                {
                    if (PlayerInfo[i][pFMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);

            }

        }

    }
    return 1;

}
Reply
#2

pawn Код:
CMD:members(playerid, params[])

{
    if(IsPlayerConnected(playerid))

    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new teamnumber;
        if (PlayerInfo[playerid][pLeader] != 0) teamnumber = PlayerInfo[playerid][pLeader];
        else if (PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
        else if (PlayerInfo[playerid][pFMember] != 255) teamnumber = PlayerInfo[playerid][pFMember];
        else

        {
            SendClientMessage(playerid, COLOR_GRAD1, "You are not a member of an organization!");
            return 1;

        }
        SendClientMessage(playerid, 0x808000AA, "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] || PlayerInfo[i][pMember])

                {
                    if (PlayerInfo[i][pLeader] == teamnumber)

                    {
                        format(string, sizeof(string), "%s (Leader)",sendername);

                    }
                    else if (PlayerInfo[i][pMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                else if(PlayerInfo[i][pFMember] != 255)

                {
                    if (PlayerInfo[i][pFMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);

            }

        }

    }
    return 1;

}
you need to change the "playerid"s inside of your loop to "i", as it should be the ID of the other player, not your's (playerid = ID of the player that used the command).. Mine should work...

btw, it's not needed to check for "IsPlayerConnected(playerid)" when a player uses a command. A player can't use a command if he's not connected... (the first line in your command itself)
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
CMD:members(playerid, params[])

{
    if(IsPlayerConnected(playerid))

    {
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new teamnumber;
        if (PlayerInfo[playerid][pLeader] != 0) teamnumber = PlayerInfo[playerid][pLeader];
        else if (PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
        else if (PlayerInfo[playerid][pFMember] != 255) teamnumber = PlayerInfo[playerid][pFMember];
        else

        {
            SendClientMessage(playerid, COLOR_GRAD1, "You are not a member of an organization!");
            return 1;

        }
        SendClientMessage(playerid, 0x808000AA, "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] || PlayerInfo[i][pMember])

                {
                    if (PlayerInfo[i][pLeader] == teamnumber)

                    {
                        format(string, sizeof(string), "%s (Leader)",sendername);

                    }
                    else if (PlayerInfo[i][pMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                else if(PlayerInfo[i][pFMember] != 255)

                {
                    if (PlayerInfo[i][pFMember] == teamnumber)

                    {
                        format(string, sizeof(string), "%s, Rank: %d.",sendername, PlayerInfo[i][pRank]);

                    }

                }
                if (strlen(string) > 1) SendClientMessage(playerid, 0xF5DEB3AA, string);

            }

        }

    }
    return 1;

}
you need to change the "playerid"s inside of your loop to "i", as it should be the ID of the other player, not your's (playerid = ID of the player that used the command).. Mine should work...

btw, it's not needed to check for "IsPlayerConnected(playerid)" when a player uses a command. A player can't use a command if he's not connected... (the first line in your command itself)
About the [i] function, I was actually thinking about that. But I was not sure. Thanks AGAIN Sascha!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)