Dialog list with multiple result from query
#1

Hi I need to create a dialog list with data drawn from a sql query only that I can not understand how to do with this code shows me only the last result of the query while I need to show them all the code is this:

PHP код:
forward GetSkinsForPlayer(playerid);
public 
GetSkinsForPlayer(playerid)
{
    new 
rows, razza, age, fat,aged, sex, dialogo[1024];
    
razza = 1; 
    
age = pInfo[playerid][pAge];
    
sex = pInfo[playerid][pSex];
    
aged = age+5;
    
fat = 0; 
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
s_model, s_age, s_razza, s_fat;
        for(new 
i; i<rows; i++)
        {
            
cache_get_value_int(i, "skinModel", s_model);
            
cache_get_value_int(i, "skinAge", s_age);
            
cache_get_value_int(i, "skinRazza", s_razza);
            
cache_get_value_int(i, "skinFat", s_fat);
            
printf("Skin Model ID: %d - Age: %d - Razza: %d - Fat: %d ",s_model, s_age, s_razza, s_fat);
            
format(dialogo, sizeof(dialogo), "[%d] Modello Skin: %d - Etа: %d - %d\n",i,s_model, s_age, aged);
        }
        
ShowPlayerDialog(playerid, DIALOG_SKIN_SELECT, DIALOG_STYLE_LIST, "Seleziona Skin", dialogo, "Scegli", "Chiudi");
    }
    return 
true;
} 
Sorry for my bad english
Reply
#2

You have to create two strings and use strcat

Код:
new str1[512], str2[100];
//loop
format(str2, sizeof str2, ...);
strcat(str1, str2);
In your code, you format actual row, but the row before is overwritten.
Reply
#3

Thanks so much rep +
Reply


Forum Jump:


Users browsing this thread: