Command stuck server
#6

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:
PHP код:
CMD:factions(playeridparams[])
{
    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 
icache_get_row_count(); ji++)
    {
        new 
            
groupId cache_get_row_int(i0handle),
            
members cache_get_row_int(i1handle);
            
        if(
<= groupId sizeof(groupVariables))
        {
            new 
temp[64];
            
format(tempsizeof(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(outputtemp);
        }
        
    }
    
    
cache_delete(result);
    
ShowPlayerDialog(playerid4500DIALOG_STYLE_TABLIST_HEADERS"Factions List"output"Select""Cancel");
    return 
1;

Reply


Messages In This Thread
Command stuck server - by Nin9r - 23.01.2017, 14:09
Re: Command stuck server - by jlalt - 23.01.2017, 14:18
Re: Command stuck server - by Nin9r - 23.01.2017, 14:35
Re: Command stuck server - by Vince - 23.01.2017, 15:23
Re: Command stuck server - by Nin9r - 23.01.2017, 15:32
Re: Command stuck server - by Vince - 23.01.2017, 16:23
Re: Command stuck server - by Nin9r - 23.01.2017, 16:47

Forum Jump:


Users browsing this thread: 1 Guest(s)