28.06.2018, 07:22
String lenght is too high
28.06.2018, 20:07
29.06.2018, 02:49
Quote:
No need of using 9000 as as strlen is only 1080 after removing {FFFFFF} which was useless as its white by default.
|
@OP: You can't bypass the limit.You should split your contents into "multiple pages"
29.06.2018, 05:48
Use less color codes. If you're only using {FFFFFF} you can completely omit them and set the label color to white. No sense in using colors when they never change.
Also why do you do the list by hand? Just use an array (which can be found in for example fsdebug) and format it using a loop. 3 minutes of work instead of an hour.
Also why do you do the list by hand? Just use an array (which can be found in for example fsdebug) and format it using a loop. 3 minutes of work instead of an hour.
29.06.2018, 06:03
You can use this code to do multiple pages:
Definition:
Variable:
Array:
Function:
Command:
When player press "Select", use ShowPlayerVehicleDialog
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; }
29.06.2018, 07:03
Quote:
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; } |
Each case corresponds to an item of the array?
29.06.2018, 14:44
Quote:
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? |
PHP код:
new vehList[][] = {
{"{FFFFFF}BMX"},
};
PHP код:
new vehList[][] = {
//model, price, name
{481, 500, "{FFFFFF}BMX"},
{593, 125000, "{FFFFFF}Dodo"},
{587, 25000, "{FFFFFF}Euros"}
};
PHP код:
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
}
...
}
29.06.2018, 16:13
Quote:
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 код:
|
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");
}
PHP код:
new vehList[][] = {
//model, price, name
{481, 500, "{FFFFFF}BMX"},
{593, 125000, "{FFFFFF}Dodo"},
{587, 25000, "{FFFFFF}Euros"}
};
30.06.2018, 20:43
lil bump
01.07.2018, 20:51
Bumpin’
01.07.2018, 20:52
stuupid, your string cant be bigger then limit.
01.07.2018, 22:25
If you are refferring to the 4096 character limit, then you’re simply either blind or dumb. We’ve been talking about it since page 2. I was just asking for help on the page system. Yet if you can’t read or answer properly, please don’t.
« Next Oldest | Next Newest »
Users browsing this thread: 6 Guest(s)