Quote:
Originally Posted by shitbird
Like I wrote,
Him pressing "Back" is the same as (!return).
Meaning, go to the Dialog where he can press "Back", if there isn't a response, then open the previous dialog with ShowPlayerDialog.
|
Back is a listitem and not the second button
And to your problem
But just some code improvements before
pawn Код:
//OnDialogResponse
if(dialogid == 99 && response) {
new string[256]; //only one string
if(listitem == 0) { //switch is only useful for more items, not for two
format(string, ...);
ShowPlayerDialog(...);
} else {
format(string, ...);
ShowPlayerDialog(...);
}
return 1; //just to stop the code, would be a waste to check for the other dialogids if we already know that its 99
}
if((dialogid == 79 || dialogid == 78) && response) { //and and or is like * and +, && gets checked first! so we need the bracket
Now to the problem
pawn Код:
if(dialogid == 79){carid = Aarray[listitem], money = AMarray[listitem], S = 8;}
if(dialogid == 78){carid = Harray[listitem], money = HMarray[listitem], S = 6;}
That code will crash if the listitem is bigger than the size of the array
And that happens with "Back", Aarray (size 8 - last item 7) and back is 8
So what to do, just some little changes
pawn Код:
if((dialogid == 79 || dialogid == 78) && response) {
new vehicle, carid, money; //static and constant arrays, no need to recreate them if nothing changes
static const Aarray[] = {592,577,511,512,593,553,519,513};
static const AMarray[] = {Andromada,AT-400,Beagle,Cropduster,Dodo,Nevada,Shamal,Stuntplane};
static const Harray[] = {548,417,487,488,563,469};
static const HMarray[] = {Cargobob,Leviathan,Maverick,NewsMaverick,Raindance,Sparrow};
if(dialogid == 79) {
if(listitem == sizeof(Aarray)) return ShowPlayerDialog(playerid, 99, DIALOG_STYLE_LIST,"Select","Airplanes\nHelicopters","Select","Cancle");
carid = Aarray[listitem], money = AMarray[listitem];
} else { //the other id
if(listitem == sizeof(Harray)) return ShowPlayerDialog(playerid, 99, DIALOG_STYLE_LIST,"Select","Airplanes\nHelicopters","Select","Cancle");
carid = Harray[listitem], money = HMarray[listitem];
}
//the checkpoint code
return 1; //the return again
}