Dialog list furniture
#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


Messages In This Thread
Dialog list furniture - by HypCosmin - 08.02.2019, 20:20
Re: Dialog list furniture - by TokicMajstor - 08.02.2019, 21:00
Re: Dialog list furniture - by Pottus - 08.02.2019, 21:03

Forum Jump:


Users browsing this thread: 1 Guest(s)