Dialog list furniture
#1

Good evening, how can I make the dialog below be in multiple lists? I mean I add in a dialog (example: 25 lines in 5 pages), thank you!


OnDialogResponse
PHP код:
        if(listitem == 0)
        {
            new list[
2048];
            
format(list, sizeof(list), ""C_ALB"#\t"C_ALB"Obiect\t"C_ALB"Pret\n");
            for(new 
isizeof(HouseFurnitures); ++i)
            {
                
format(list, sizeof(list), "%s%d\t%s\t"C_MONE"$%s\n", list, i+1HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
            }
           
ShowPlayerDialog(playeridDIALOG_FURNITURE_BUYDIALOG_STYLE_TABLIST_HEADERS""C_DIA"Meniu casa", list, "Buy""Back");
        }
        if(
listitem == 0)
        {
            new list[
2048];
            
format(list, sizeof(list), ""C_ALB"#\t"C_ALB"Obiect\t"C_ALB"Pret\n");
            for(new 
isizeof(HouseFurnitures); ++i)
            {
                
format(list, sizeof(list), "%s%d\t%s\t"C_MONE"$%s\n", list, i+1HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
            }
           
ShowPlayerDialog(playeridDIALOG_FURNITURE_BUYDIALOG_STYLE_TABLIST_HEADERS""C_DIA"Meniu casa", list, "Buy""Back");
        } 
PHP код:
    if(dialogid == DIALOG_FURNITURE_BUY)
    {
        if(!
response) return ShowHouseMenu(playerid);
        new 
id InHouse[playerid];
        if(
id == INVALID_HOUSE_ID) return SCM(playerid0xE74C3CFF""C_SRV"SERVER:"C_TXT" Nu va aflati in casa dvs. personala.");
        if(
strcmp(HouseData[id][Owner], Player_GetName(playerid))) return SCM(playerid0xE74C3CFF""C_SRV"SERVER:"C_TXT" Nu esti proprietarul acesti case personale.");
        if(
HouseData[id][SalePrice] > 0) return SCM(playerid0xE74C3CFF""C_SRV"SERVER:"C_TXT" Atata timp cat casa dvs. este pusa in vanzare nu puteti folosi aceasta actiune.");
        if(
HouseFurnitures[listitem][Price] > GetPlayerMoney(playerid)) return SCM(playerid0xE74C3CFF""C_SRV"SERVER:"C_TXT" Nu ai suficienti bani pentru a utiliza aceasta actiune!");
        
GivePlayerCash(playerid, -HouseFurnitures[listitem][Price]);
        
Update(playeridpCashx);
        
format(stringssizeof(strings), "~r~-%s",FormatNumber(HouseFurnitures[listitem][Price]));
        
GameTextForPlayer(playeridstrings50003);
        
SCM(playerid0xFFFFFFFF""C_SRV"SERVER:"C_SKI" Pentru a misca camera, apasati  tasta "C_ALB"SPACE"C_SKI" iar pentru a misca obiectul, apasa click pe (X,Y,Z).");
        
SCM(playerid0xFFFFFFFF""C_SRV"SERVER:"C_SKI" Iar pentru a anula actiunea apasati tasta "C_ALB"ESC"C_SKI", obiectul o sa fie spawnat (in locul initial).");
        new 
FloatxFloatyFloatz;
        
GetPlayerPos(playeridxyz);
        
GetXYInFrontOfPlayer(playeridxy3.0);
        new 
objectid CreateDynamicObject(HouseFurnitures[listitem][ModelID], xyz0.00.00.0GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
        
mysql_format(handlequerysizeof(query), "INSERT INTO housefurnitures SET HouseID=%d, FurnitureID=%d, FurnitureX=%f, FurnitureY=%f, FurnitureZ=%f, FurnitureVW=%d, FurnitureInt=%d"idlistitemxyzGetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
        new 
Cacheadd mysql_query(handlequery), data[e_furniture];
        
data[SQLID] = cache_insert_id();
        
data[HouseID] = id;
        
data[ArrayID] = listitem;
        
data[furnitureX] = x;
        
data[furnitureY] = y;
        
data[furnitureZ] = z;
        
data[furnitureRX] = 0.0;
        
data[furnitureRY] = 0.0;
        
data[furnitureRZ] = 0.0;
        
cache_delete(add);
        
Streamer_SetArrayData(STREAMER_TYPE_OBJECTobjectidE_STREAMER_EXTRA_IDdata);
        
        
EditingFurniture[playerid] = true;
        
EditDynamicObject(playeridobjectid);
        return 
1;
    } 
Reply
#2

You could make a button for cancellation to be button for next page. But that new page must be tottaly new dialog. Or you can make last dialog option to be next page and then put: case %lastcase% { ShowPlayDialog( next page ...) }
Reply
#3

You kind of go like this I didn't test it or anything but take a look at how it works.

Код:
#define         FURNITURE_PER_PAGE          25

if(listitem == 0)
{
	new list[2048];
    format(list, sizeof(list), ""C_ALB"#\t"C_ALB"Obiect\t"C_ALB"Pret\n");
    for(new i = g_CurrFurnPage[playerid] * FURNITURE_PER_PAGE; i < sizeof(HouseFurnitures); ++i)
    {
    	format(list, sizeof(list), "%s%d\t%s\t"C_MONE"$%s\n", list, i+1, HouseFurnitures[i][Name], convertNumber(HouseFurnitures[i][Price]));
	}
	format(list, sizeof(list), "%s\nNext Page\nLast Page");
	ShowPlayerDialog(playerid, DIALOG_FURNITURE_BUY, DIALOG_STYLE_TABLIST_HEADERS, ""C_DIA"Meniu casa", list, "Buy", "Back");
}

if(dialogid == DIALOG_FURNITURE_BUY)
{
	if(!response || !inputtext[0]) return ShowHouseMenu(playerid);
	
	// Player clicked next page
	if(!strcmp(inputtext, "Next Page"))
	{
		// Check to make sure that there is more items to list
		if( (g_CurrFurnPage[playerid] * FURNITURE_PER_PAGE) < sizeof(list) ) g_CurrFurnPage[playerid]++;
        ShowHouseMenu(playerid);
	}
	// Player clicked last page
	else if(!strcmp(inputtext, "Last Page"))
	{
		// Can never be less than 0 no additional checks required!
		if(g_CurrFurnPage[playerid] > 0) g_CurrFurnPage[playerid]--;

		// Not sure if this is the right function but you need to show them the list again
		ShowHouseMenu(playerid);
	}
	
	// Player clicked some other list item
	else
	{
	}
}
All you are doing is saving which page they are on then offsetting your array reference with the following formula.

(CurrPage * ItemsPerpage) + listitem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)