Checking if a player is online using their name.
#1

I have a command to do the following:

pawn Код:
command(members, playerid, params[])
{
    if(PVar[playerid][factionID] < 1)
    {
        SendClientMessage(playerid, 0x66666666, "You are not currently in a faction");
        return 1;
    }
    else
    {
        new Query[128], members, memberrankdisp[24];
        new resultline[200], membername[24], memberrank;
        new membersonline = 0, membersstring[128];
        new memberlist1[128];
        new dialog[1024];
        format(Query, sizeof(Query), "SELECT `username`, `factionRank` FROM `playerinfo` WHERE `factionID` = '%d'", PVar[playerid][factionID]);
        mysql_query(Query);
        mysql_store_result();
       
        memberrank = PVar[playerid][factionRank];
        for(new i=0; i < mysql_num_rows(); i++)
        {
            if(mysql_fetch_row_format(resultline))
            {
                //you can now use sscanf, explode, split or strtok to split result
                sscanf(resultline,"p<|>s[24]d", membername, memberrank);
                if(IsPlayerConnected(i))
                {
                    format(dialog,sizeof(dialog),"%s\n{004000}• {FFFFFF}%s, (%s | Rank: %d)",dialog, membername, FactionRankToName(PVar[playerid][factionID], memberrank), memberrank);
                }
                else
                {
                    format(dialog,sizeof(dialog),"%s\n{BF0000}• {FFFFFF}%s, (%s | Rank: %d)",dialog, membername, FactionRankToName(PVar[playerid][factionID], memberrank), memberrank);
                }
            }
        }
        members = mysql_num_rows();
        for(new i=0; i < members; i++)
        {
            if(IsPlayerConnected(i))
            {
                membersonline++;
            }
        }
        format(membersstring, sizeof(membersstring), "%s - Members online: {FFFFFF}(%d/%d)", FVar[PVar[playerid][factionID]][factionname], membersonline, members);
        ShowPlayerDialog(playerid, MEMBERS, DIALOG_STYLE_LIST, membersstring, dialog, "Close", "");
        return 1;
    }
}
BUT, As you can see here:

pawn Код:
if(IsPlayerConnected(i))
                {
                    format(dialog,sizeof(dialog),"%s\n{004000}• {FFFFFF}%s, (%s | Rank: %d)",dialog, membername, FactionRankToName(PVar[playerid][factionID], memberrank), memberrank);
                }
                else
                {
                    format(dialog,sizeof(dialog),"%s\n{BF0000}• {FFFFFF}%s, (%s | Rank: %d)",dialog, membername, FactionRankToName(PVar[playerid][factionID], memberrank), memberrank);
                }
It checks to see if the id of the player is online, rather than the name in the list, meaning if there are two members online, the top two will go green. Any ideas how to work around this?
Reply


Messages In This Thread
Checking if a player is online using their name. - by vIBIENNYx - 10.09.2012, 20:22
Re: Checking if a player is online using their name. - by vIBIENNYx - 11.09.2012, 15:52
Re: Checking if a player is online using their name. - by jameskmonger - 11.09.2012, 16:14
Re: Checking if a player is online using their name. - by vIBIENNYx - 11.09.2012, 16:28
Re: Checking if a player is online using their name. - by jameskmonger - 11.09.2012, 17:54

Forum Jump:


Users browsing this thread: 1 Guest(s)