SA-MP Forums Archive
Hi pro people, please come here :D - 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: Hi pro people, please come here :D (/showthread.php?tid=640691)



Hi pro people, please come here :D - kAn3 - 06.09.2017

Hi all.
I am (not that) new to scripting.
My problem is that I'm a self-thaught guy and sometimes I need help in understandings things.
I'd really love to understand better the "array index out of bonds" messages, along with these
Код:
[debug] #0 0001f3ec in public OnRandomCallback () from example.amx
error codes, in this case that #0 0001f3ec.. I don't know what it can be. Is there any way to learn what that error code could mean?
It is really late here, if you don't get my post I can edit it later!
Thanks in advance to whoever will reply here


Re: Hi pro people, please come here :D - Paulice - 06.09.2017

Array index out of bounds means the script is trying to access an index of an array that isn't within its min and max value. For example: new array[5], printf("%i", array[10]);

As you can see 10 is not within its min and max value; thus, the error!

-----

"in public OnRandomCallback ()" - You don't have to pay attention to the address at the beginning, simply review the function it's pointing out.


Re: Hi pro people, please come here :D - kAn3 - 06.09.2017

Great! Can you only explain me better the
Quote:

"in public OnRandomCallback ()" - You don't have to pay attention to the address at the beginning, simply review the function it's pointing out.

thing please? I feel a bit retarded still


Re: Hi pro people, please come here :D - Spmn - 06.09.2017

That hex number is the address where the error occured.
Luckily, crashdetect is smart enough to print the faulty line number instead of address if you compile your script with debug info: https://github.com/Zeex/samp-plugin-...ith-debug-info


Re: Hi pro people, please come here :D - n00blek - 06.09.2017

Array out of bounds means when you define for example #define BANKS 4 but ypu actually have more than 4 banks in script(thats just example). You can fix this error by increasing value of array.


Re: Hi pro people, please come here :D - 10MIN - 06.09.2017

@n00blek it is just an definition. Your full example would be like:
PHP код:
#define BANKS 4
new Banks[BANKS]; //here you declare an array with 4 cells. For the Compiler after the PreCompiling Stages it would be : new Banks[4];
//Somewhere
Banks[4] = some_value//Here you "overflowed" the array Banks. 



Re: Hi pro people, please come here :D - n00blek - 06.09.2017

Well i didnt show with code i just gave idea how it works


Re: Hi pro people, please come here :D - 10MIN - 06.09.2017

@n00blek you just gave a definition, nothing else... -_-
Definition: #define SOMETHING SOMETHING2
Array: new Array[Cell_Number];

See the difference?


Re: Hi pro people, please come here :D - kAn3 - 06.09.2017

Quote:
Originally Posted by Spmn
Посмотреть сообщение
That hex number is the address where the error occured.
Luckily, crashdetect is smart enough to print the faulty line number instead of address if you compile your script with debug info: https://github.com/Zeex/samp-plugin-...ith-debug-info
Hey, thanks for replying!
I already do compile with -d3, atm I don't have that problem, but I wanna know more! I need to know the meaning of these error codes! I am sure somewhere there is an explanation :c