SA-MP Forums Archive
ShowPlayerDialog crash - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ShowPlayerDialog crash (/showthread.php?tid=104741)



ShowPlayerDialog crash - Dreftas - 26.10.2009

pawn Код:
for(new k=0; k<MAX_CARS; k++) {
    format(ShowDlg,sizeof(ShowDlg),"%s%s\t%d$\n",ShowDlg,HouseCarName[k],HouseCarPrice[k]);
}
ShowPlayerDialog(playerid, id, DIALOG_STYLE_LIST, "House Car", ShowDlg, "Buy", "Cancel");
This code crash server. Does anyone know why?

ShowDlg i set to [1024] cells.
At the end(after all format() ) ShowDlg have about 300 symbols and there is 17 list items. Maybe text limit in ShowPlayerDialog is less than 300 ? In sa-mp wiki limits doesn't say anything about dialogs..



Re: ShowPlayerDialog crash - Joe Staff - 26.10.2009

4096 is the limit on dialoginfo.

How large is "MAX_CARS" ?


Re: ShowPlayerDialog crash - Dreftas - 26.10.2009

Quote:
Originally Posted by Joe Staff
How large is "MAX_CARS" ?
Its 17


Re: ShowPlayerDialog crash - Joe Staff - 26.10.2009

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Joe Staff
4096 is the limit on dialoginfo.
Oh really? It got increased?
I vaguely recall Kye saying that in the 0.3a beta notes before he took it down.
"\t" is an escape code used to indent, Kye also added that (I believe around the same release)

The only thing I can think of that would cause that crash is the creation of ShowDlg, show us, from that line to your loop there.


Re: ShowPlayerDialog crash - Dreftas - 26.10.2009

Removing \t doesn't helped :/

Quote:
Originally Posted by Joe Staff
The only thing I can think of that would cause that crash is the creation of ShowDlg, show us, from that line to your loop there.
pawn Код:
forward ShowDialog(playerid, id);
public ShowDialog(playerid, id)
{
    new ShowDlg[1024];
    if(id == 1) {
// code
} else if(id == 2) {
// code > and here goes dialogs until id 11, id 11 is cars dialog
    } else if(id == 11) {
        for(new k=0; k<MAX_CARS; k++) {
            format(ShowDlg,sizeof(ShowDlg),"%s%s - %d$\n",ShowDlg,HouseCarName[k],HouseCarPrice[k]);
        }
        ShowPlayerDialog(playerid, id, DIALOG_STYLE_LIST, "House Car", ShowDlg, "Buy", "Cancel");
    } else if(id == 12) {
        // other dialog
    } else if(id == 13) {
        //other dialog
    }
    return id; 
}



Re: ShowPlayerDialog crash - Dreftas - 26.10.2009

Quote:
Originally Posted by Seif_
Use strins like I said...
I didn't used this function before Can you give some example ?


Re: ShowPlayerDialog crash - Dreftas - 26.10.2009

pawn Код:
new InsertStr[128];
        for(new k=0; k<MAX_CARS; k++) {
            format(InsertStr,sizeof(InsertStr),"%s - %d$\n",HouseCarName[k],HouseCarPrice[k]);
            strins(InsertStr,ShowDlg,strlen(ShowDlg));
        }
        ShowPlayerDialog(playerid, id, DIALOG_STYLE_LIST, "House Car", ShowDlg, "Buy", "Cancel");
I don't know am I using strins right, but this crashes too
More suggests pls


Re: ShowPlayerDialog crash - Dreftas - 26.10.2009

pawn Код:
new string[128];
        for(new k=0; k<MAX_CARS; k++)
        {
            format(string,128,"%s - %d$\n",HouseCarName[k],HouseCarPrice[k]);
            strins(ShowDlg,string,strlen(ShowDlg));
        }
        ShowPlayerDialog(playerid, id, DIALOG_STYLE_LIST, "House Car", ShowDlg, "Buy", "Cancel");
Still crashes


Re: ShowPlayerDialog crash - Danny_Costelo - 26.10.2009

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Joe Staff
4096 is the limit on dialoginfo.
Oh really? It got increased?
Yup, http://forum.sa-mp.com/index.php?topic=119892.0 - Refer to the RC6-1 update.


Re: ShowPlayerDialog crash - Dabombber - 26.10.2009

There's nothing wrong with using format to append stuff to a string, in fact it's probably better than using strins since you won't have to worry about buffer overflows. You might want to do it differently so you don't get the trailing newline though.

pawn Код:
format(ShowDlg, sizeof(ShowDlg), "%s - %d$", HouseCarName[0], HouseCarPrice[0]);
for(new k = 1; k < MAX_CARS; k++) {
    format(ShowDlg, sizeof(ShowDlg), "%s\n%s - %d$", ShowDlg, HouseCarName[k], HouseCarPrice[k]);
}
ShowPlayerDialog(playerid, id, DIALOG_STYLE_LIST, "House Car", ShowDlg, "Buy", "Cancel");
About the crashing, put a bunch of print statements in to see which line is crashing it.