runtime error 4 +Rep
#1

well,here is what happens when i save :
pawn Код:
//under ongamemode exit.
    for(new i = 0; i < MAX_IDS; i++)
    {
        if(idinfo[i][use] == 1)
        {
            SaveID(i);
        }
    }
pawn Код:
public SaveID(id)
{
        if(idinfo[i][use] == 1)
        {
            for(new i = 0; i < 10; i++)
            {
                if(numberidinfo[id][used] == 1)
                {
                    new query[700];
                    mysql_format(dbHandle,query, sizeof(query), "UPDATE `id` SET `iduse`=%d,`idid`=%d,`idkind`=%d,`iddo`=%d,`idpx`=%f,`idpy`=%f,`idpz`=%f,`idrx`=%f,`idry`=%f,`idrz`='%f',`idin`=%d,`idvw`=%d WHERE `idnum`=%d AND `id`=%d",
                    idinfo[id][IDUSE][i], idinfo[id][IDID][i], idinfo[id][IDKIND][i], idinfo[id][IDDO][i], idinfo[id][IDPX][i],
                    idinfo[id][IDPY][i], idinfo[id][IDPZ][i], idinfo[id][IDRX][i], idinfo[id][IDRY][i], idinfo[id][IDRZ][i]
                     ,idinfo[id][IDIN][i], idinfo[id][IDVW][i], id, i);
                    printf("\n %s", query);
                    mysql_tquery(mysql, query, "", "");
                    printf("Saved ID %d", id);
                    printf("%d updated", i);
                }
            }
        }
        return 1;
}
runtime error:
Код:
[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 00024134 in ?? () from gm.amx
[debug] #1 0000c81c in ?? () from gm.amx
[debug] #2 00009f6c in public OnGameModeExit () from gm.amx
NOTE:Lets say there was 5 created ID's and were saved,it shows at index 6 bound 5,always like that
when i removed this it worked without runtime error
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=347895
Reply
#3

First of all, you can get the exact line: https://github.com/Zeex/samp-plugin-...ith-debug-info

Again, when you create an array with size 10, the VALID indexes are 0-9 therebefore 10 would cause run time error 4.

I'll assume the mistake is in this line until you done the above:
pawn Код:
if(numberidinfo[id][used] == 1)
What would be the point to loop without using "i" as index so you most likely used "id" by accident.
Reply


Forum Jump:


Users browsing this thread: