Hi pro people, please come here :D
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

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
Reply
#5

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.
Reply
#6

@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. 
Reply
#7

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

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

See the difference?
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)