07.08.2015, 03:33
So I'm trying to make a simple /factions command which will go through the database and see how many players are in a specific faction. Currently I have this:
Unfortunately, this isn't working as it's returning 1 for each faction when it should only return 1 for one faction, and 0 for the rest. I feel like I'm using the wrong function where "cache_get_row_count()" is, but I'm not sure what the correct function is. Any help would be appreciated. Thanks!
pawn Код:
CMD:factions(playerid, params[])
{
new str[128];
for(new f; f < MAX_FACTIONS; f++)
{
if(FactionInfo[f][FactionType] != 0)
{
// Faction Exists
format(str, 128, "[FID: %d] Name: %s | Members: %d", f, FactionInfo[f][FactionName], GetFactionMembers(f));
SendClientMessage(playerid, -1, str);
}
}
return 1;
}
stock GetFactionMembers(factionid)
{
new query[200];
mysql_format(con, query, sizeof(query), "SELECT * FROM `players` WHERE `faction` = '%d'", factionid);
mysql_tquery(con, query, "Actual_GetFactionMembers", "i", factionid);
return 1;
}
stock Actual_GetFactionMembers(factionid)
{
new str[128];
format(str, 128, "%d", cache_get_row_count());
return str;
}