10.09.2012, 16:17
Basically, I want to retrieve all the members from the MySQL database of a certain faction and display it inside the dialog, here's what I have so far:
I want to add a line for each member too, any help would be appreciated.
pawn Code:
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];
format(Query, sizeof(Query), "SELECT `username` & `factionRank` FROM `playerinfo` WHERE `factionID` = '%d'", PVar[playerid][factionID]);
mysql_query(Query);
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);
}
members = mysql_num_rows();
for(new i=0; i < members; i++)
{
if(IsPlayerConnected(i))
{
membersonline++;
}
}
format(membersstring, sizeof(membersstring), "%s - Members online: (%d/%d)", FVar[PVar[playerid][factionID]][factionname], membersonline, members);
ShowPlayerDialog(playerid, MEMBERS, DIALOG_STYLE_LIST, membersstring, " ", "Close", "");
for(new i; i < members; i++)
{
//
}
return 1;
}
}