PDA

View Full Version : Array error


IndependentGaming
23/01/2015, 04:34 PM
Greetings i made someting dynamic but it give me this error when i start the server
[18:11:11] [debug] Run time error 4: "Array index out of bounds"
[18:11:11] [debug] Accessing element at index 20 past array upper bound 19
[18:11:11] [debug] AMX backtrace:
[18:11:11] [debug] #0 000c9ee4 in public OnLoadViplockerPoints () from DCRP.amx
[18:11:11] [LoadDynamicDoors] 2000 doors rehashed/loaded.
[18:11:11] [LoadDynamicMapIcons] 1 map icons rehashed/loaded.
[18:11:11] [LoadDynamicTexts] 1000 Texts Labels rehashed/loaded.


in the gamemode i have no errors

thanks in advance

ATGOggy
23/01/2015, 04:36 PM
Show OnLoadViplocker()

Luca12
23/01/2015, 04:36 PM
Post here your public OnLoadViplockerPoints ()

IndependentGaming
23/01/2015, 04:37 PM
forward OnLoadViplockerPoints();
public OnLoadViplockerPoints()
{
new i, rows, fields, tmp[128], string[128];
cache_get_data(rows, fields, MainPipeline);

while(i < rows)
{
cache_get_field_content(i, "id", tmp, MainPipeline); ViplockerPoints[i][viplockerSQLId] = strval(tmp);
cache_get_field_content(i, "PosX", tmp, MainPipeline); ViplockerPoints[i][viplockerPosX] = floatstr(tmp);
cache_get_field_content(i, "PosY", tmp, MainPipeline); ViplockerPoints[i][viplockerPosY] = floatstr(tmp);
cache_get_field_content(i, "PosZ", tmp, MainPipeline); ViplockerPoints[i][viplockerPosZ] = floatstr(tmp);
cache_get_field_content(i, "VW", tmp, MainPipeline); ViplockerPoints[i][viplockerVW] = strval(tmp);
cache_get_field_content(i, "Int", tmp, MainPipeline); ViplockerPoints[i][viplockerInt] = strval(tmp);
if(ViplockerPoints[i][viplockerPosX] != 0)
{
format(string, sizeof(string), "Vip Locker #%d\nType /viplocker to open it.", i);
ViplockerPoints[i][viplockerTextID] = CreateDynamic3DTextLabel(string, COLOR_PURPLE, ViplockerPoints[i][viplockerPosX], ViplockerPoints[i][viplockerPosY], ViplockerPoints[i][viplockerPosZ]+0.6, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ViplockerPoints[i][viplockerVW], ViplockerPoints[i][viplockerInt], -1);
}
i++;
}
}

Jay_
23/01/2015, 04:42 PM
Just because there are no errors when compiling doesn't necessarily suggest that there will not be any errors during runtime. The PAWN compiler is extremely dumb compared to most modern compilers.

As the error suggests one of your array indexes are out of bounds. Judging by the code you have provided this is most likely present in the ViplockerPoints array. You need to do some research as to what this means as you are likely to experience this often. Search these forums as the questions has been answered many times before.

IndependentGaming
23/01/2015, 04:44 PM
Just because there are no errors when compiling doesn't necessarily suggest that there will not be any errors during runtime. The PAWN compiler is extremely dumb compared to most modern compilers.

As the error suggests one of your array indexes are out of bounds. Judging by the code you have provided this is most likely present in the ViplockerPoints array. You need to do some research as to what this means as you are likely to experience this often. Search these forums as the questions has been answered many times before.

can it be in the mysql database ?

IndependentGaming
23/01/2015, 04:47 PM
Problem has been solved

Thanks to Jay_