20.08.2017, 09:59
A limit is a limit. Your size isn't actually 10,000. You could probably prevent this from happening by losing the colors but if you don't want to there's another method I think could work for you.
What could you do is split the info onto 2 separate dialogs.
Here's an example:
Put those at the top of your script.
What this does is every 30 items it breaks off and you could go to another page where the next 30 will be there and so on and so on.
To use the listed item, do this with your dialog response.
Let me know if there are any errors. I wrote this up real quick.
What could you do is split the info onto 2 separate dialogs.
Here's an example:
PHP код:
#define MAX_PAGE_SHOW 30
new PlayerCarBuyPage[MAX_PLAYERS];
new CarBuySelector[MAX_PLAYERS][MAX_PAGE_SHOW+3];
PHP код:
stock ShowVehicleBuy(playerid, page)
{
new
str[1250],
counter = 0
;
PlayerCarBuyPage[playerid] = page;
if(page == 1)
str = "{FFFF00}List 1\n";
else
format(str, sizeof(str), "%s{FFFF00}<< List %d\n", str, page-1);
for(new i = 0; i < MAX_PERSONAL_CARS; i++)
{
if(Stock[i][vType] == 1)
{
counter++;
}
}
new
bool:toSecondPage = false,
countfind = 0
;
for(new i = page*MAX_PAGE_SHOW; i < counter; i++)
{
countfind++;
if(countfind == MAX_PAGE_SHOW+1)
{
toSecondPage = true;
break;
}
else
{
format(str, sizeof(str), "%s{ffffff}%s ( %d{33cc33}${ffffff} ) ( {00FFFF}%d {ffffff}cars in stock)\n", str, Stock[xf][vName], Stock[xf][vPrice], Stock[xf][vStock]);
CarBuySelector[playerid][countfind-1] = i;
}
}
if(toSecondPage)
format(str, sizeof(str), "%s{FFFF00}List %d >>\n", str, (page+1)+1);
ShowPlayerDialog(playerid, DIALOG_CARBUY2, DIALOG_STYLE_LIST, "Buy a car", str, "Select", "Cancel");
return 1;
}
To use the listed item, do this with your dialog response.
PHP код:
case DIALOG_CARBUY2:
{
if(response)
{
if(listitem == 0)
{
if(PlayerCarBuyPage[playerid] == 1)
ShowVehicleBuy(playerid, 1);
else
ShowVehicleBuy(playerid, PlayerCarBuyPage[playerid]-1);
return 1;
}
if(listitem == MAX_PAGE_SHOW+1)
{
return ShowVehicleBuy(playerid, PlayerCarBuyPage[playerid]+1);
}
//To use the selected item:
new idx = CarBuySelector[playerid][listitem-1];
}
}