OMG, How many times will I have to say it? Read previous posts.
|
OMG, How many times will we have to say it? You can't bypass the limit.
|
No need of using 9000 as as strlen is only 1080 after removing {FFFFFF} which was useless as its white by default.
|
#define MAX_LINE_PER_PAGE 30
static playerPage[MAX_PLAYERS] = {0, ...};
new vehList[][] = { {"{FFFFFF}BMX"}, };
ShowPlayerVehicleDialog(playerid) { static msg[30 * MAX_LINES_PER_PAGE], page = playerPage[playerid], i = page; // opimisation for (; i < sizeof vehList; i++) { if (i != 0 && (i - MAX_LINES_PER_PAGE) > MAX_LINES_PER_PAGE) break; // if player page is 0 then continue strcat(msg, sizeof msg, "\n"); strcat(msg, sizeof msg, vehList[i]); } if (playerPage[playerid] >= sizeof vehList) { SendClientMessage(playerid, -1, "Dialog closed."); playerPage[playerid] = 0; return false; } ShowPlayerDialog(playerid, DIALOG_VEHICLES, DIALOG_STYLE_LIST, "Vehicle List", msg, "Select", "Next"); return false; // this means the code successfully worked }
CMD:vehiclelist(playerid) { ShowPlayerVehicleDialog(playerid); return 1; }
You can use this code to do multiple pages:
Definition: Код:
#define MAX_LINE_PER_PAGE 30 Код:
static playerPage[MAX_PLAYERS] = {0, ...}; Код:
new vehList[][] = { {"{FFFFFF}BMX"}, }; Код:
ShowPlayerVehicleDialog(playerid) { static msg[30 * MAX_LINES_PER_PAGE], page = playerPage[playerid], i = page; // opimisation for (; i < sizeof vehList; i++) { if (i != 0 && (i - MAX_LINES_PER_PAGE) > MAX_LINES_PER_PAGE) break; // if player page is 0 then continue strcat(msg, sizeof msg, "\n"); strcat(msg, sizeof msg, vehList[i]); } if (playerPage[playerid] >= sizeof vehList) { SendClientMessage(playerid, -1, "Dialog closed."); playerPage[playerid] = 0; return false; } ShowPlayerDialog(playerid, DIALOG_VEHICLES, DIALOG_STYLE_LIST, "Vehicle List", msg, "Select", "Next"); return false; // this means the code successfully worked } Код:
CMD:vehiclelist(playerid) { ShowPlayerVehicleDialog(playerid); return 1; } ![]() |
Alright, thanks a lot I think that will do instead. When I'm going to use OnDialogResponse, the process is the same?
Each case corresponds to an item of the array? |
new vehList[][] = {
{"{FFFFFF}BMX"},
};
new vehList[][] = {
//model, price, name
{481, 500, "{FFFFFF}BMX"},
{593, 125000, "{FFFFFF}Dodo"},
{587, 25000, "{FFFFFF}Euros"}
};
public OnDialogResponse(...)
{
...
case DIALOG_VEHICLES:
{
new modelid = vehList[listitem][0];
new price = vehList[listitem][1];
new modelName[32];
format(modelName, sizeof(modelName), vehList[listitem][2]);
... // deal with the rest
}
...
}
Yes, the listitem will be the array index. Additionally you could do this, to avoid writing a single case for each item. Change this:
PHP код:
PHP код:
PHP код:
|
case 8:
{
new price = vehList[listitem][1];
new carname = vehList[listitem][2];
new modelName[32], title[90];
format(title,sizeof(title),"{FFFFFF}Game Shop{FF0080} Available Money: %f", GetPlayerMoney(playerid);
format(modelName, sizeof(modelName), "%s {FF0080}$%s", carname, price);
ShowPlayerDialog(playerid, DIALOG_SHOPVEHICLES, DIALOG_STYLE_LIST, title, modelName, "Select", "Close");
}
new vehList[][] = {
//model, price, name
{481, 500, "{FFFFFF}BMX"},
{593, 125000, "{FFFFFF}Dodo"},
{587, 25000, "{FFFFFF}Euros"}
};