array index out of bounds
#1

Code:
 error 032: array index out of bounds (variable "DevBug")
 error 032: array index out of bounds (variable "DevBug")
 error 032: array index out of bounds (variable "DevBug")
pawn Code:
stock LoadBugs()
{
    new file[64];
    format(file, sizeof(file), "buglist.ini");
    format(DevBug[1][dBugs], 128, "%s", dini_Get(file, "BR1"));
    format(DevBug[2][dBugs], 128, "%s", dini_Get(file, "BR2"));
    format(DevBug[3][dBugs], 128, "%s", dini_Get(file, "BR3"));
    format(DevBug[4][dBugs], 128, "%s", dini_Get(file, "BR4"));
    format(DevBug[5][dBugs], 128, "%s", dini_Get(file, "BR5"));
    format(DevBug[6][dBugs], 128, "%s", dini_Get(file, "BR6"));
    format(DevBug[7][dBugs], 128, "%s", dini_Get(file, "BR7"));
    format(DevBug[8][dBugs], 128, "%s", dini_Get(file, "BR8"));
    format(DevBug[9][dBugs], 128, "%s", dini_Get(file, "BR9"));
    format(DevBug[10][dBugs], 128, "%s", dini_Get(file, "BR10"));
    format(DevBug[11][dBugs], 128, "%s", dini_Get(file, "BR11"));
    format(DevBug[12][dBugs], 128, "%s", dini_Get(file, "BR12"));
    format(DevBug[13][dBugs], 128, "%s", dini_Get(file, "BR13"));
    format(DevBug[14][dBugs], 128, "%s", dini_Get(file, "BR14"));
    format(DevBug[15][dBugs], 128, "%s", dini_Get(file, "BR15"));
    return 1;
}
pawn Code:
new DevBug[MAX_BUGS][dBugs];
#define MAX_BUGS 16
Reply
#2

Try to define MAX_BUGS then define DevBug and counting in scripting is from zero , so it will be like this if 16 :
pawn Code:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
Reply
#3

You can also try this.
pawn Code:
stock LoadBugs() { new file[64]; format(file, sizeof(file), "buglist.ini"); format(DevBug[0][dBugs], 128, "%s", dini_Get(file, "BR1")); format(DevBug[1][dBugs], 128, "%s", dini_Get(file, "BR2")); format(DevBug[2][dBugs], 128, "%s", dini_Get(file, "BR3")); format(DevBug[3][dBugs], 128, "%s", dini_Get(file, "BR4")); format(DevBug[4][dBugs], 128, "%s", dini_Get(file, "BR5")); format(DevBug[5][dBugs], 128, "%s", dini_Get(file, "BR6")); format(DevBug[6][dBugs], 128, "%s", dini_Get(file, "BR7")); format(DevBug[7][dBugs], 128, "%s", dini_Get(file, "BR8")); format(DevBug[8][dBugs], 128, "%s", dini_Get(file, "BR9")); format(DevBug[9][dBugs], 128, "%s", dini_Get(file, "BR10")); format(DevBug[10][dBugs], 128, "%s", dini_Get(file, "BR11")); format(DevBug[11][dBugs], 128, "%s", dini_Get(file, "BR12")); format(DevBug[12][dBugs], 128, "%s", dini_Get(file, "BR13")); format(DevBug[13][dBugs], 128, "%s", dini_Get(file, "BR14")); format(DevBug[14][dBugs], 128, "%s", dini_Get(file, "BR15")); return 1; }
Please give +rep if I helped
Reply
#4

@Swalhalla .. what?

@David You only changed 1-15 to 0-14 ? And no doesn't work.

Ah I see what you guys mean now. But no, doesn't work.
Reply
#5

Quote:
Originally Posted by Facerafter
View Post
@Swalhalla .. what?
I think my code is your answer to what he stated..
Reply
#6

Show your definition of dBugs.
Reply
#7

0 - 15 is the correct
pawn Code:
#define MAX_BUGS 16
new DevBug[MAX_BUGS][dBug];
Reply
#8

pawn Code:
enum dBugs
{
    dBug[128]
}
Sawalha, that may be. But it doesn't work.
Reply
#9

Quote:
Originally Posted by Facerafter
View Post
pawn Code:
enum dBugs
{
    dBug[128]
}
Sawalha, that may be. But it doesn't work.
Did you try mine yet?
Reply
#10

You had to use "dBug" in the format and not "dBugs". You don't need an enum for that if you're going to have only 1 string so:
pawn Code:
#define MAX_BUGS 16

new DevBug[MAX_BUGS][128];
pawn Code:
strcpy(DevBug[0], dini_Get(file, "BR1"), 128);
...
strcpy(DevBug[15],dini_Get(file, "BR15"), 128);
pawn Code:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)