10.09.2012, 20:22
I have a command to do the following:
BUT, As you can see here:
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?
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;
}
}
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);
}