23.01.2017, 16:23
Never use row_count if the primary objective of a query is to get a count of something. That's extremely inefficient because the entire result needs to be processed and sent over, rather than just one value.
This is more or less all that you need:
This is more or less all that you need:
PHP код:
CMD:factions(playerid, params[])
{
new
output[1024] = "Name\tMembers\tApplications\tScore",
Cache:result = mysql_query(handle, "SELECT playerGroup, COUNT(*) AS members FROM playeraccounts GROUP BY playerGroup HAVING members > 0 ORDER BY playerGroup");
for(new i, j = cache_get_row_count(); i < j; i++)
{
new
groupId = cache_get_row_int(i, 0, handle),
members = cache_get_row_int(i, 1, handle);
if(0 <= groupId < sizeof(groupVariables))
{
new temp[64];
format(temp, sizeof(temp),"{%s}%s\t[%d/%d]\t%s\tLevel %d",
groupVariables[groupId][gColor],
groupVariables[groupId][gGroupName],
members,
groupVariables[groupId][gSlots],
(groupVariables[groupId][gGroupAplication] == 1) ? ("AppOn") : ("AppOff"),
groupVariables[groupId][gGroupLvl]
);
strcat(output, temp);
}
}
cache_delete(result);
ShowPlayerDialog(playerid, 4500, DIALOG_STYLE_TABLIST_HEADERS, "Factions List", output, "Select", "Cancel");
return 1;
}