Command list - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command list (
/showthread.php?tid=649787)
Command list -
Nin9r - 15.02.2018
Hello!
I have command /factions which showing all the factions of my server.
The problem is that is showing just those factions who have more than 1 member.
How to change the query to show all the factions even if one of them is empty?
Command:
Код HTML:
CMD:factions(playerid, params[])
{
#pragma unused params
new
output[1024] = "Name\tMembers\tStats\tLv",
Cache:result7 = 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 < 16)
{
new temp[128];
format(temp, sizeof(temp),"{%s}%s\t[%d/%d]\t%s\tLevel %d\n",
groupVariables[groupId][gColor],
groupVariables[groupId][gGroupName],
members,
groupVariables[groupId][gSlots],
(groupVariables[groupId][gGroupAplication] == 1) ? ("Recruit") : ("Don't recruit"),
groupVariables[groupId][gGroupLvl]
);
strcat(output, temp);
}
}
cache_delete(result7);
ShowPlayerDialog(playerid, 4500, DIALOG_STYLE_TABLIST_HEADERS, "Factions", output, "Select", "Cancel");
return 1;
}
What I tried?
I tried to change
Код HTML:
mysql_query(handle, "SELECT playerGroup, COUNT(*) AS members FROM playeraccounts GROUP BY playerGroup HAVING members > 0 ORDER BY playerGroup");
to
Код HTML:
mysql_query(handle, "SELECT playerGroup, COUNT(*) AS members FROM playeraccounts GROUP BY playerGroup ORDER BY playerGroup");
and
Код HTML:
mysql_query(handle, "SELECT playerGroup, COUNT(*) AS members FROM playeraccounts GROUP BY playerGroup HAVING members >= 0 ORDER BY playerGroup");
Re: Command list -
N0FeaR - 20.02.2018
Do you still need help with this?
Re: Command list -
KDyer - 24.02.2018
This should work fine, in your MySQL Query you are limiting the factions to those with more than one member.
new mysqlQuery;
mysqlQuery = "SELECT playerGroup, COUNT(*) AS members FROM playeraccounts GROUP BY playerGroup ORDER BY playerGroup"
mysql_query(handle, mysqlQuery);
Re: Command list -
kingmk - 24.02.2018
Why u SELECT * FROM playeraccounts, when u need to SELECT * FROM factions.
Re: Command list -
Nin9r - 02.03.2018
doesn't work... any ideas?
Re: Command list -
PepsiCola23 - 02.03.2018
As @kingmc said , you cant select from playeraccounts because it will only display the factions with atleast one member. You have to make a separate table for factions and work around that table.
Re: Command list -
Nin9r - 23.03.2018
i have already that table named 'factions'. can i make a query to list all the factions from there and show some other informations from playeraccounts?