Run Time Error 4: "Array index out of bounds"
#1

Hi guys!
I have a problem with my gm, I compile successful my Gamemode but when I buy a Vehicle, compare this on server log.
Код:
[11:47:12] [debug] Run time error 4: "Array index out of bounds"
[11:47:12] [debug]   Accessing element at negative index -30000
[11:47:12] [debug] Backtrace:
[11:47:12] [debug] #0  0010285c in ?? () from vx-rp.amx
[11:47:12] [debug] #1  00116c70 in public OnDialogResponse () from vx-rp.amx
I don't know nothing about this, can you help me?
Reply
#2

did you buy a car worth $30000? ot what is the Array[-30000] supposed to access?
find anything that fits that 30000 value, and check out all enums/arays which gets (ab)used as pointer, like
pawn Код:
new number=-30000;
new pointer[10]={10,3,84,24,41,12,53,1,46,13};
new result=pointer[number];
when number equals -30000, then pointer[-30000] is invalid
Reply
#3

Yes but now I Change the price, from 3000 to 31000 but compare the same error
Reply
#4

its not about changing the prices, its the algorithm. the script is fucking up a (most prolly positive) value, the 30000 gets changed to -30000, causing the script to fail when accessing a negative adress..
however, i doubt that simply changing/removing a minus "-" char from a formula will make the script work.
i cant imagine any circumstance where you need an array with 30000 cells, concerning vehicles - the maximum vehicle amount is 2000, so there is a design flaw somewhere. give us some code to examine, i cant predict what will happen when you try to access Array[30000] instead of [-30000]. instead of stopping, it will most prolly return the same error (out of bounds) due to the wrong value used (30000) as pointer:
use -30000 as pointer, and tell the price inside cell -30000. wrong.
use 30000 as pointer, and tell the price inside cell 30000. wrong too.
its more like
use X as pointer, and tell the price inside cell X. should return 30000.
when X is a small value like 25, "car number 25" ( Array[25]=30000; ) could store the value: 30000 or -30000, where Array[30000]=25; is indeed looking similar, but is significally different.
Reply
#5

I can give you a code in private, if you have skype you can add me: LuPePy
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)