When a player type /factions server goes stuck for few seconds.
Код HTML:
CMD:factions(playerid, params[])
{
new members,members2,members3,members4,members5,members6,members7,members8,members9,members10,members11,members12,members13,members14,members15;
for(new xf = 0; xf < MAX_GROUPS; xf++)
{
if(strlen(groupVariables[xf][gGroupName]) >= 1 && strcmp(groupVariables[xf][gGroupName], "None", true))
{
new stringy2[256];
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '1'");
new Cache: resultx = mysql_query (handle, stringy2);
members = cache_get_row_count();
cache_delete(resultx);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '2'");
new Cache: resultx2 = mysql_query (handle, stringy2);
members2 = cache_get_row_count();
cache_delete(resultx2);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '3'");
new Cache: resultx3 = mysql_query (handle, stringy2);
members3 = cache_get_row_count();
cache_delete(resultx3);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '4'");
new Cache: resultx4 = mysql_query (handle, stringy2);
members4 = cache_get_row_count();
cache_delete(resultx4);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '5'");
new Cache: resultx5 = mysql_query (handle, stringy2);
members5 = cache_get_row_count();
cache_delete(resultx5);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '6'");
new Cache: resultx6 = mysql_query (handle, stringy2);
members6 = cache_get_row_count();
cache_delete(resultx6);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '7'");
new Cache: resultx7 = mysql_query (handle, stringy2);
members7 = cache_get_row_count();
cache_delete(resultx7);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '8'");
new Cache: resultx8 = mysql_query (handle, stringy2);
members8 = cache_get_row_count();
cache_delete(resultx8);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '9'");
new Cache: resultx9 = mysql_query (handle, stringy2);
members9 = cache_get_row_count();
cache_delete(resultx9);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '10'");
new Cache: resultx10 = mysql_query (handle, stringy2);
members10 = cache_get_row_count();
cache_delete(resultx10);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '11'");
new Cache: resultx11 = mysql_query (handle, stringy2);
members11 = cache_get_row_count();
cache_delete(resultx11);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '12'");
new Cache: resultx12 = mysql_query (handle, stringy2);
members12 = cache_get_row_count();
cache_delete(resultx12);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '13'");
new Cache: resultx13 = mysql_query (handle, stringy2);
members13 = cache_get_row_count();
cache_delete(resultx13);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '14'");
new Cache: resultx14 = mysql_query (handle, stringy2);
members14 = cache_get_row_count();
cache_delete(resultx14);
mysql_format(handle, stringy2, 256, "SELECT * FROM `playeraccounts` WHERE `playerGroup` = '15'");
new Cache: resultx15 = mysql_query (handle, stringy2);
members15 = cache_get_row_count();
cache_delete(resultx15);
new param10[64],param11[64],param12[74],param13[64],param2[128],param3[64],param4[64],param5[64],param14[64],param15[64],param6[64],param7[64],param8[64],param9[74],param1[256],param16[64],param17[64];
// szMessage = "Faction Name\tMembers\n";
new lockedz[64];
if(groupVariables[1][gGroupAplication] == 1) {lockedz = "AppOn";}
else {lockedz = "AppOff";}
new lockedz2[64];
if(groupVariables[2][gGroupAplication] == 1) {lockedz2 = "AppOn";}
else {lockedz2 = "AppOff";}
new lockedz3[64];
if(groupVariables[3][gGroupAplication] == 1) {lockedz3 = "AppOn";}
else {lockedz3 = "AppOff";}
new lockedz4[64];
if(groupVariables[4][gGroupAplication] == 1) {lockedz4 = "AppOn";}
else {lockedz4 = "AppOff";}
new lockedz5[64];
if(groupVariables[5][gGroupAplication] == 1) {lockedz5 = "AppOn";}
else {lockedz5 = "AppOff";}
new lockedz6[64];
if(groupVariables[6][gGroupAplication] == 1) {lockedz6 = "AppOn";}
else {lockedz6 = "AppOff";}
new lockedz7[64];
if(groupVariables[7][gGroupAplication] == 1) {lockedz7 = "AppOn";}
else {lockedz7 = "AppOff";}
new lockedz8[64];
if(groupVariables[8][gGroupAplication] == 1) {lockedz8 = "AppOn";}
else {lockedz8 = "AppOff";}
new lockedz9[64];
if(groupVariables[9][gGroupAplication] == 1) {lockedz9 = "AppOn";}
else {lockedz9 = "AppOff";}
new lockedz10[64];
if(groupVariables[10][gGroupAplication] == 1) {lockedz10 = "AppOn";}
else {lockedz10 = "AppOff";}
new lockedz11[64];
if(groupVariables[11][gGroupAplication] == 1) {lockedz11 = "AppOn";}
else {lockedz11 = "AppOff";}
new lockedz12[64];
if(groupVariables[12][gGroupAplication] == 1) {lockedz12 = "AppOn";}
else {lockedz12 = "AppOff";}
new lockedz13[64];
if(groupVariables[13][gGroupAplication] == 1) {lockedz13 = "AppOn";}
else {lockedz13 = "AppOff";}
new lockedz14[64];
if(groupVariables[14][gGroupAplication] == 1) {lockedz14 = "AppOn";}
else {lockedz14 = "AppOff";}
new lockedz15[64];
if(groupVariables[15][gGroupAplication] == 1) {lockedz15 = "AppOn";}
else {lockedz15 = "AppOff";}
param10 = "Name\tMembers\tApplications\tScore";
param15 = "Factions";
format(param1, sizeof(param1),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[1][gColor],groupVariables[1][gGroupName], members, groupVariables[1][gSlots], lockedz, groupVariables[1][gGroupLvl]);
format(param2, sizeof(param2),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[2][gColor],groupVariables[2][gGroupName], members2, groupVariables[2][gSlots], lockedz2, groupVariables[2][gGroupLvl]);
format(param3, sizeof(param3),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[3][gColor],groupVariables[3][gGroupName], members3, groupVariables[3][gSlots],lockedz3, groupVariables[3][gGroupLvl]);
format(param4, sizeof(param4),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[4][gColor],groupVariables[4][gGroupName], members4, groupVariables[4][gSlots],lockedz4, groupVariables[4][gGroupLvl]);
format(param5, sizeof(param5),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[5][gColor],groupVariables[5][gGroupName], members5, groupVariables[5][gSlots],lockedz5, groupVariables[5][gGroupLvl]);
format(param6, sizeof(param6),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[6][gColor],groupVariables[6][gGroupName], members6, groupVariables[6][gSlots],lockedz6, groupVariables[6][gGroupLvl]);
format(param7, sizeof(param7),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[7][gColor],groupVariables[7][gGroupName], members7, groupVariables[7][gSlots],lockedz7, groupVariables[7][gGroupLvl]);
format(param8, sizeof(param8),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[8][gColor],groupVariables[8][gGroupName], members8, groupVariables[8][gSlots],lockedz8, groupVariables[8][gGroupLvl]);
format(param9, sizeof(param9),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[9][gColor],groupVariables[9][gGroupName],members9, groupVariables[9][gSlots],lockedz9, groupVariables[9][gGroupLvl]);
format(param11, sizeof(param11),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[10][gColor],groupVariables[10][gGroupName], members10, groupVariables[10][gSlots],lockedz10, groupVariables[10][gGroupLvl]);
format(param12, sizeof(param12),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[11][gColor],groupVariables[11][gGroupName], members11, groupVariables[11][gSlots],lockedz11, groupVariables[11][gGroupLvl]);
format(param13, sizeof(param13),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[12][gColor],groupVariables[12][gGroupName], members12, groupVariables[12][gSlots],lockedz12, groupVariables[12][gGroupLvl]);
format(param14, sizeof(param14),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[13][gColor],groupVariables[13][gGroupName], members13, groupVariables[13][gSlots],lockedz13, groupVariables[13][gGroupLvl]);
format(param16, sizeof(param16),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[14][gColor],groupVariables[14][gGroupName], members14, groupVariables[14][gSlots],lockedz14, groupVariables[14][gGroupLvl]);
format(param17, sizeof(param16),"{%s}%s\t[%d/%d]\t%s\tLevel %d", groupVariables[15][gColor],groupVariables[15][gGroupName], members15, groupVariables[15][gSlots],lockedz15, groupVariables[15][gGroupLvl]);
format(szMessage, sizeof(szMessage), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",param10,param15,param1,param2,param3,param4,param5,param6,param7,param8,param9,param11,param12,param13,param14,param16,param17);
}
}
ShowPlayerDialog(playerid, 4500, DIALOG_STYLE_TABLIST_HEADERS,"Factions List", szMessage, "Select", "Cancel");
SelFaction[playerid] = 0;
return 1;
}
You're loading all table data but only to count rows so you really don't need to select all, best way is to use thraded querys, but you may try changing
You can't actually be serious with this, can you? It hurts my eyes just to look at it. If you're only interested in the number of players in each group then use this
Thank you Vince.
I don't know how to use it. Can you show me?
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.
Thank you so much Vince. #respect.