AMX Backtrace
#1

Hi! I have a problem, i found these errors in my server_log.txt:
Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 48 past array upper bound 47
[debug] AMX backtrace:
[debug] #0 0002d804 in public OnPlayerEnterCheckpoint (playerid=0)
and script problem is:
Код:
new DMVOStep1[49];
Код:
for(new obj = 0; obj < 50; obj++) 
{
    DestroyDynamicObject(DMVOStep1[obj]);
}
Reply
#2

The problem was
Код:
for(new obj = 0; obj < 50; obj++)
The solving:
Код:
for(new obj = 0; obj < sizeof(DMVOStep1); obj++)
Thanks anyway! ^^
Reply
#3

PHP код:
for(new obj 0sizeof(DMVOStep1); obj jobj++) 
Reply
#4

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
PHP код:
for(new obj 0sizeof(DMVOStep1); obj jobj++) 
That is wrong.

sizeof is a compile time operator which means the compiler replaces all instances of sizeof with the actual number. So there is no need for one to create an extra variable to store the constant. In fact, the extra variable makes the loop slower since it involves fetching a variable from memory for every iteration.
Reply
#5

u array is of 49 elements means 0-48 in index number
a simple fix would be
Код:
for(new obj = 0; obj < 49; obj++)
Reply
#6

Or use
PHP код:
new DMVOStep1[50]; 
Then your array will have indices ranging from 0 to 49 (as it has 50 cells).

An array with 49 cells is such a weird number.
Reply
#7

He already solved the issue......
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)