PDA

Просмотр полной версии : [Вопрос] Run time error 4: "Array index out of bounds"



WinLock
18.09.2014, 13:11
Здравствуйте, подскажете пожалуйста как исправить ошибку?

Выход из предела массива



[10:58:44] [debug] Run time error 4: "Array index out of bounds"
[10:58:44] [debug] Accessing element at index 16 past array upper bound 15
[10:58:44] [debug] AMX backtrace:
[10:58:44] [debug] #0 0014ac04 in public LoadBizz () at C:\Users\winlock\Desktop\test\gamemodes\new.pwn:18264


Сами строки



publics: LoadBizz()
{
static rows, fields;
cache_get_data(rows, fields);
new temp[64]; new string2[300]; new i = 0;
if(rows)
{
for(new he = 0; he < rows; he++)
{
cache_get_row(he, 0, temp), BizzInfo[he][bID] = strval(temp);
cache_get_row(he, 1, temp), BizzInfo[he][bOwned] = strval(temp);
cache_get_row(he, 2, temp), strmid(BizzInfo[he][bOwner], temp, 0, strlen(temp), 255);
cache_get_row(he, 3, temp), strmid(BizzInfo[he][bMessage], temp, 0, strlen(temp), 255);
cache_get_row(he, 4, temp), strmid(BizzInfo[he][bExtortion], temp, 0, strlen(temp), 255);
cache_get_row(he, 5, temp), BizzInfo[he][bEntranceX] = floatstr(temp);
cache_get_row(he, 6, temp), BizzInfo[he][bEntranceY] = floatstr(temp);
cache_get_row(he, 7, temp), BizzInfo[he][bEntranceZ] = floatstr(temp);
cache_get_row(he, 8, temp), BizzInfo[he][bExitX] = floatstr(temp);
cache_get_row(he, 9, temp), BizzInfo[he][bExitY] = floatstr(temp);
cache_get_row(he, 10, temp), BizzInfo[he][bExitZ] = floatstr(temp);
cache_get_row(he, 11, temp), BizzInfo[he][bBuyPrice] = strval(temp);
cache_get_row(he, 12, temp), BizzInfo[he][bEntranceCost] = strval(temp);
cache_get_row(he, 13, temp), BizzInfo[he][bTill] = strval(temp);
cache_get_row(he, 14, temp), BizzInfo[he][bLocked] = strval(temp);
cache_get_row(he, 15, temp), BizzInfo[he][bInterior] = strval(temp);
cache_get_row(he, 16, temp), BizzInfo[he][bProducts] = strval(temp);
cache_get_row(he, 17, temp), BizzInfo[he][bMaxProducts] = strval(temp);
cache_get_row(he, 18, temp), BizzInfo[he][bPriceProd] = strval(temp);
cache_get_row(he, 19, temp), BizzInfo[he][b2Till] = strval(temp);
cache_get_row(he, 20, temp), BizzInfo[he][bCena] = strval(temp);
cache_get_row(he, 21, temp), BizzInfo[he][bBarX] = floatstr(temp);
cache_get_row(he, 22, temp), BizzInfo[he][bBarY] = floatstr(temp);
cache_get_row(he, 23, temp), BizzInfo[he][bBarZ] = floatstr(temp);
cache_get_row(he, 24, temp), BizzInfo[he][bMafia] = strval(temp);
cache_get_row(he, 25, temp), BizzInfo[he][bVirtual] = strval(temp);
i++;
if(BizzInfo[he][bOwned] == 0)
{
format(string2, sizeof(string2), "{00FF32}Цена:{FEFEFE} %d\n{F5FF00}Бизнес продаётся",BizzInfo[he][bBuyPrice]);
BizzInfo[he][bLocked] = 1;
Create3DTextLabel("~~~~~~~~~~~~~~~~~\nИспользуте команду\nв данном месте\n~~~~~~~~~~~~~~~~~",COLOR_YELLOW,BizzInfo[he][bBarX],BizzInfo[he][bBarY],BizzInfo[he][bBarZ],20.0,0,1);
BizzInfo[he][bLabel] = Create3DTextLabel(string2,COLOR_YELLOW,BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ],20.0,0,1);
BizzInfo[he][bPickupV] = AddStaticPickup(19132, 23, BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ]);
BizzInfo[he][bPickupE] = AddStaticPickup(1318, 23, BizzInfo[he][bExitX], BizzInfo[he][bExitY], BizzInfo[he][bExitZ], BizzInfo[he][bVirtual]);
}
else if(BizzInfo[he][bOwned] == 1)
{
format(string2,sizeof(string2), "{F0F0F0}%s\nВладелец:\n {00A5FF}%s", BizzInfo[he][bMessage], BizzInfo[he][bOwner]);
BizzInfo[he][bLabel] = Create3DTextLabel(string2,TEAM_GROVE_COLOR,BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ],20.0,0,1);
BizzInfo[he][bPickupV] = AddStaticPickup(19132, 23, BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ]);
BizzInfo[he][bPickupE] = AddStaticPickup(1318, 23, BizzInfo[he][bExitX], BizzInfo[he][bExitY], BizzInfo[he][bExitZ], BizzInfo[he][bVirtual]);
}
else
{
BizzInfo[he][bOwned] = 1;
format(string2,sizeof(string2), "{F0F0F0}%s\nВладелец:\n {00A5FF}%s", BizzInfo[he][bMessage], BizzInfo[he][bOwner]);
BizzInfo[he][bLabel] = Create3DTextLabel(string2,TEAM_GROVE_COLOR,BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ],20.0,0,1);
BizzInfo[he][bPickupV] = AddStaticPickup(19132, 23, BizzInfo[he][bEntranceX], BizzInfo[he][bEntranceY], BizzInfo[he][bEntranceZ]);
BizzInfo[he][bPickupE] = AddStaticPickup(1318, 23, BizzInfo[he][bExitX], BizzInfo[he][bExitY], BizzInfo[he][bExitZ], BizzInfo[he][bVirtual]);
}
}
printf("[Загружено бизнесов]: <%d>",i);
}
else printf("Бизнесов не загружены.");
return true;
}

nekaz
18.09.2014, 13:17
18264 где эта строчка?

WinLock
18.09.2014, 13:23
cache_get_row(he, 0, temp), BizzInfo[he][bID] = strval(temp);

- - - Добавлено - - -


cache_get_row(he, 0, temp), BizzInfo[he][bID] = strval(temp);

Не эта а вот эта



cache_get_row(he, 1, temp), BizzInfo[he][bOwned] = strval(temp);

DeimoS
18.09.2014, 15:58
Число ячеек в BizzInfo не равно числу строк в таблице.

WinLock
18.09.2014, 16:28
Число ячеек в BizzInfo не равно числу строк в таблице.

Как я понял new BizzInfo[16][bInfo]; а в таблице bizz 26 строк это в Структура значит надо добавить 27 в bizzinfo

- - - Добавлено - - -


Число ячеек в BizzInfo не равно числу строк в таблице.

Спасибо

DeimoS
18.09.2014, 16:47
Closed