SA-MP Forums Archive
String lenght is too high - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: String lenght is too high (/showthread.php?tid=655647)

Pages: 1 2


Re: String lenght is too high - xMoBi - 28.06.2018

Quote:
Originally Posted by Adamoneoone
Посмотреть сообщение
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.


Re: String lenght is too high - Adamoneoone - 28.06.2018

bumperino

Quote:
Originally Posted by xMoBi
Посмотреть сообщение
OMG, How many times will we have to say it? You can't bypass the limit.
The thing is, I know it's possible, as i've seen it working fully on another server. If it wasn't possible, I wouldn't even have posted this in the first place.


Re: String lenght is too high - GhostHacker9 - 29.06.2018

Quote:
Originally Posted by Zeth
Посмотреть сообщение
No need of using 9000 as as strlen is only 1080 after removing {FFFFFF} which was useless as its white by default.
No the embeds are not "removed" or rendered at compile time they are still characters.It's only rendered at runtime.

@OP: You can't bypass the limit.You should split your contents into "multiple pages"


Re: String lenght is too high - NaS - 29.06.2018

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.


Re: String lenght is too high - xMoBi - 29.06.2018

You can use this code to do multiple pages:

Definition:
Код:
#define        MAX_LINE_PER_PAGE        30
Variable:
Код:
static        playerPage[MAX_PLAYERS] = {0, ...};
Array:
Код:
new vehList[][] = {
        {"{FFFFFF}BMX"},
};
Function:
Код:
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
}
Command:
Код:
CMD:vehiclelist(playerid) {
        ShowPlayerVehicleDialog(playerid);
        return 1;
}
When player press "Select", use ShowPlayerVehicleDialog


Re: String lenght is too high - Adamoneoone - 29.06.2018

Quote:
Originally Posted by xMoBi
Посмотреть сообщение
You can use this code to do multiple pages:

Definition:
Код:
#define        MAX_LINE_PER_PAGE        30
Variable:
Код:
static        playerPage[MAX_PLAYERS] = {0, ...};
Array:
Код:
new vehList[][] = {
        {"{FFFFFF}BMX"},
};
Function:
Код:
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
}
Command:
Код:
CMD:vehiclelist(playerid) {
        ShowPlayerVehicleDialog(playerid);
        return 1;
}
When player press "Select", use ShowPlayerVehicleDialog
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?


Re: String lenght is too high - Sasino97 - 29.06.2018

Quote:
Originally Posted by Adamoneoone
Посмотреть сообщение
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?
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 код:
new vehList[][] = {
        {
"{FFFFFF}BMX"},
}; 
To this:

PHP код:
new vehList[][] = {
        
//model, price, name
        
{481500"{FFFFFF}BMX"},
        {
593125000"{FFFFFF}Dodo"},
        {
58725000"{FFFFFF}Euros"}
}; 
And then

PHP код:
public OnDialogResponse(...)
{
    ...
    case 
DIALOG_VEHICLES:
    {
        new 
modelid vehList[listitem][0];
        new 
price vehList[listitem][1];
        new 
modelName[32];
        
format(modelNamesizeof(modelName), vehList[listitem][2]);
        ... 
// deal with the rest
    
}
    ...

(Untested)


Re: String lenght is too high - Adamoneoone - 29.06.2018

Quote:
Originally Posted by Sasino97
Посмотреть сообщение
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 код:
new vehList[][] = {
        {
"{FFFFFF}BMX"},
}; 
To this:

PHP код:
new vehList[][] = {
        
//model, price, name
        
{481500"{FFFFFF}BMX"},
        {
593125000"{FFFFFF}Dodo"},
        {
58725000"{FFFFFF}Euros"}
}; 
And then

PHP код:
public OnDialogResponse(...)
{
    ...
    case 
DIALOG_VEHICLES:
    {
        new 
modelid vehList[listitem][0];
        new 
price vehList[listitem][1];
        new 
modelName[32];
        
format(modelNamesizeof(modelName), vehList[listitem][2]);
        ... 
// deal with the rest
    
}
    ...

(Untested)
Hey mate, I tried doing this:
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(modelNamesizeof(modelName), "%s {FF0080}$%s"carnameprice);
        
ShowPlayerDialog(playeridDIALOG_SHOPVEHICLESDIALOG_STYLE_LISTtitlemodelName"Select""Close");
    } 
With your:
PHP код:
new vehList[][] = {
        
//model, price, name
        
{481500"{FFFFFF}BMX"},
        {
593125000"{FFFFFF}Dodo"},
        {
58725000"{FFFFFF}Euros"}
}; 
However, when I go ingame, nothing shows at all


Re: String lenght is too high - Adamoneoone - 30.06.2018

lil bump


Re: String lenght is too high - Adamoneoone - 01.07.2018

Bumpin’


Re: String lenght is too high - CodeStyle175 - 01.07.2018

stuupid, your string cant be bigger then limit.


Re: String lenght is too high - Adamoneoone - 01.07.2018

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
stuupid, your string cant be bigger then limit.
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.