Crashdetect Array Index out of bounds. - 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: Crashdetect Array Index out of bounds. (
/showthread.php?tid=490921)
Crashdetect Array Index out of bounds. -
[WSF]ThA_Devil - 28.01.2014
thank you...
Re: Crashdetect Array Index out of bounds. -
Konstantinos - 28.01.2014
Load
crashdetect plugin and
compile with debug info. Re-compile your scripts, start the server and let that diaog appear again. In case it prints anything, post the server log.
Re: Crashdetect Array Index out of bounds. -
[WSF]ThA_Devil - 28.01.2014
Quote:
Originally Posted by Konstantinos
Load crashdetect plugin and compile with debug info. Re-compile your scripts, start the server and let that diaog appear again. In case it prints anything, post the server log.
|
Код:
[20:38:16] [debug] Run time error 4: "Array index out of bounds"
[20:38:16] [debug] Accessing element at negative index -1
[20:38:16] [debug] AMX backtrace:
[20:38:16] [debug] #0 00013c04 in public OnDialogResponse (playerid=0, dialogid=16501, response=1, listitem=-1, inputtext[]=@0x00030988 "") at gamemode.pwn:605
That's what it did output
-- I think I might know what's the prob... gotta create temp varriable, since the textbox doesn't carry "listitem" over
Re: Crashdetect Array Index out of bounds. -
Konstantinos - 28.01.2014
listitem is -1. What's the line 605?
Before using listitem inside [] in the array HelpMeListItem, you should check if the value is not out of bounds.
pawn Код:
if (0 <= listitem < 25)
{
// you can use listitem in HelpMeListItem with safety here
}
else return // error..
Re: Crashdetect Array Index out of bounds. -
[WSF]ThA_Devil - 28.01.2014
Quote:
Originally Posted by Konstantinos
listitem is -1. What's the line 605?
Before using listitem inside [] in the array HelpMeListItem, you should check if the value is not out of bounds.
pawn Код:
if (0 <= listitem < 25) { // you can use listitem in HelpMeListItem with safety here }
|
I managed to fix it by storing listitem from PREVIOUS dialog into an array, so it can be carried over to DIALOG_STYLE_MSGBOX response...