[Array index out of bounds] problem.
#1

[debug] Run time error 4: "Array index out of bounds"
[debug] Accessing element at index 10 past array upper bound 9
[debug] AMX backtrace:
[debug] #0 00066fb0 in ?? (0x00000001, 0x05f92ad4) from lsrp.amx
[debug] #1 0009a534 in public LoadDynamicHouses () from lsrp.amx


Okay, so I keep getting this error while I start my server. I tried to figure out where the problem was but I didn't succeed. What I noticed is that if I empty the "houses" table it doesn't return the error anymore. I checked and rechecked the table,but it seems legit. Anyone has any ideas ?

Below is the code.


pawn Код:
public LoadDynamicHouses()
{
    new rows, fields;
    new total = 0, house = 1, weapons[256];
    cache_get_data(rows, fields);
    if(rows)
    {
        while(total < rows)
        {
            HouseInfo[house][hID] = cache_get_row_int(total, 0);
            HouseInfo[house][hEntranceX] = cache_get_row_float(total, 1);
            HouseInfo[house][hEntranceY] = cache_get_row_float(total, 2);
            HouseInfo[house][hEntranceZ] = cache_get_row_float(total, 3);
            HouseInfo[house][hExitX] = cache_get_row_float(total, 4);
            HouseInfo[house][hExitY] = cache_get_row_float(total, 5);
            HouseInfo[house][hExitZ] = cache_get_row_float(total, 6);
            cache_get_row(total, 7, HouseInfo[house][hInfo], dbHandle, 128);
            cache_get_row(total, 8, HouseInfo[house][hOwner], dbHandle, 128);
            HouseInfo[house][hOwned] = cache_get_row_int(total, 9);
            HouseInfo[house][hLocked] = cache_get_row_int(total, 10);
            HouseInfo[house][hPrice] = cache_get_row_int(total, 11);
            HouseInfo[house][hLevelbuy] = cache_get_row_int(total, 12);
            HouseInfo[house][hRentprice] = cache_get_row_int(total, 13);
            HouseInfo[house][hRentable] = cache_get_row_int(total, 14);
            HouseInfo[house][hInterior] = cache_get_row_int(total, 15);
            HouseInfo[house][hWorld] = cache_get_row_int(total, 16);
            HouseInfo[house][hCash] = cache_get_row_int(total, 17);
            HouseInfo[house][hFurnitures] = cache_get_row_int(total, 18);
            cache_get_row(total, 19, weapons, dbHandle, 128);
            HouseInfo[house][hCheckPosX] = cache_get_row_float(total, 20);
            HouseInfo[house][hCheckPosY] = cache_get_row_float(total, 21);
            HouseInfo[house][hCheckPosZ] = cache_get_row_float(total, 22);
            HouseInfo[house][hRadio] = cache_get_row_int(total, 23);
            HouseInfo[house][hHouseOn] = 1;
            AssignHouseWeapons(house, weapons);
            if(HouseInfo[house][hOwned] == 0)
                format(msg, sizeof(msg), "House: %d\n%s\nPrice: $%d\nLevel: %d", house, HouseInfo[house][hInfo], HouseInfo[house][hPrice], HouseInfo[house][hLevelbuy]);
            else
                format(msg, sizeof(msg), "House: %d\n%s", house, HouseInfo[house][hInfo]);
            HouseInfo[house][hLabel] = CreateDynamic3DTextLabel(msg, COLOR_HOUSE, HouseInfo[house][hEntranceX], HouseInfo[house][hEntranceY], HouseInfo[house][hEntranceZ], 3.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
            HouseInfo[house][hCheckPoint] = CreateDynamicCP(HouseInfo[house][hEntranceX], HouseInfo[house][hEntranceY], HouseInfo[house][hEntranceZ], 1.5, -1, -1, -1, 2.0);
            if(HouseInfo[house][hFurnitures] > 0)
            {
                LoadHouseFurnitures(house);
            }
            house++;
            total++;
        }
    }
    format(msg,sizeof(msg), "Loaded %d dynamic houses from MySQL.", total);
    printf(msg);
    return 1;
}
Reply


Messages In This Thread
[Array index out of bounds] problem. - by rappy93 - 17.05.2014, 17:40
Re: [Array index out of bounds] problem. - by Konstantinos - 17.05.2014, 17:44
Re: [Array index out of bounds] problem. - by rappy93 - 17.05.2014, 17:47
Re: [Array index out of bounds] problem. - by Konstantinos - 17.05.2014, 17:51
Re: [Array index out of bounds] problem. - by rappy93 - 17.05.2014, 17:56
Re: [Array index out of bounds] problem. - by Konstantinos - 17.05.2014, 18:19
Re: [Array index out of bounds] problem. - by rappy93 - 17.05.2014, 18:22
Re: [Array index out of bounds] problem. - by Konstantinos - 17.05.2014, 18:24
Re: [Array index out of bounds] problem. - by rappy93 - 17.05.2014, 18:27
Re: [Array index out of bounds] problem. - by rappy93 - 17.05.2014, 18:34

Forum Jump:


Users browsing this thread: 1 Guest(s)