Array Index Out Of Bounds
#1

Confused by this error. It's returning in the server log (server console). When I use the function.

The line is where the loop starts as in the first line after the for.

I've had to attach pictures since my internet went down!


Please see attached.

I'm making it so anytime a 911 call is placed they move up on the police computer I.e a new call equals 0 so the old 0 should move to slot 1.
Reply
#2

Can you actually upload a proper picture or even an attachment ? There is no possible way to see that image.
Reply
#3

Updated!
Reply
#4

Probably you are passing an higher index than the maximum value in PoliceCall array.

What is the size of PoliceCall?

Check if its greater than 16 as your loop has max value of 15 and since you +1, it passes 16.
Reply
#5

It has a maximum value of 15; I don't think that is the case. Because I'm adding the +1 onto the x and not looping it. Unless I'm missing something.
Reply
#6

Quote:
Originally Posted by Dokins
Посмотреть сообщение
It has a maximum value of 15; I don't think that is the case. Because I'm adding the +1 onto the x and not looping it. Unless I'm missing something.
Thats actually the problem, your loop will have a maximum value of 15 (since x < 16).

So your code is
pawn Код:
PoliceCall[x + 1][..]
Which actually is (in the last case of loop)
pawn Код:
PoliceCall[15 + 1][..]
So you see you are passing 16 over there where the maximum number it can have is 15.

The loop should be:
pawn Код:
for (new x; x < 15; x++)
(so 14 + 1 = 15, which your array can have)


Also your code is wrong, since you are adding a new entry in index 0 and then saving all the data in +1 index through loops, but you forgot that you are also moving index 0 data to 1.
So basically the new entry will be copied to index 0 and 1. (both will have the same text)

You should run the loop first and then add a new entry to slot 0.
Reply
#7

Why take a pic with ur mobile lol can't u just upload the code on pastebin or something..
Reply
#8

I'm adding a new slot before I run the loop, I don't think that's the issue.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)