Array out of bounds!
#1

Hi, so I've implemented a new system in my server using textdraws for registration, I know it might be something I've missed, but one of the textdraws(which i don't know what is it exactly as the logs show its number while in the gamemode it has got a name) causes the following errors, and bans the player clicking it after clicking on it much, as you can see..

Code:
[23:19:49] [debug] Run time error 4: "Array index out of bounds"
[23:19:49] [debug]  Attempted to read/write array element at index 1110704128 in array of size 200
[23:19:49] [debug] AMX backtrace:
[23:19:49] [debug] #0 0005d0f4 in ?? (... <2 arguments>) at ./includes/anti-aimbot.pwn:100
[23:19:49] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:19:49] [debug] #2 native CallLocalFunction () from samp03svr
[23:19:49] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:19:49] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:19:51] [debug] Run time error 4: "Array index out of bounds"
[23:19:51] [debug]  Attempted to read/write array element at index 1110704128 in array of size 1000
[23:19:51] [debug] AMX backtrace:
[23:19:51] [debug] #0 00053300 in ?? (... <2 arguments>) at D:\PAWN Scripting\Royal Life\pawno\include\PreviewModelDialog.inc:827
[23:19:51] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:19:51] [debug] #2 native CallLocalFunction () from samp03svr
[23:19:51] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:19:51] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:19:52] [debug] Run time error 4: "Array index out of bounds"
[23:19:52] [debug]  Attempted to read/write array element at index 1110704128 in array of size 1000
[23:19:52] [debug] AMX backtrace:
[23:19:52] [debug] #0 00053780 in ?? (... <2 arguments>) at D:\PAWN Scripting\Royal Life\pawno\include\PreviewModelDialog.inc:869
[23:19:52] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:19:52] [debug] #2 native CallLocalFunction () from samp03svr
[23:19:52] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:19:52] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:19:52] [debug] Run time error 4: "Array index out of bounds"
[23:19:52] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:19:52] [debug] AMX backtrace:
[23:19:52] [debug] #0 0036e28c in ?? (... <2 arguments>) at asd.pwn:41416
[23:19:52] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:19:52] [debug] #2 native CallLocalFunction () from samp03svr
[23:19:52] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:19:52] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:19:52] [debug] Run time error 4: "Array index out of bounds"
[23:19:52] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:19:52] [debug] AMX backtrace:
[23:19:52] [debug] #0 0036f948 in ?? (... <2 arguments>) at asd.pwn:41547
[23:19:52] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:19:52] [debug] #2 native CallLocalFunction () from samp03svr
[23:19:52] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:19:52] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=42) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:42] [debug] Run time error 4: "Array index out of bounds"
[23:20:42] [debug]  Attempted to read/write array element at index 1110704128 in array of size 2000
[23:20:42] [debug] AMX backtrace:
[23:20:42] [debug] #0 0038cdfc in ?? (... <2 arguments>) at asd.pwn:44112
[23:20:42] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:42] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:42] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:42] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:45] [debug] Run time error 4: "Array index out of bounds"
[23:20:45] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:45] [debug] AMX backtrace:
[23:20:45] [debug] #0 0038d4dc in ?? (... <2 arguments>) at asd.pwn:44155
[23:20:45] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:45] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:45] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:45] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:46] [debug] Run time error 4: "Array index out of bounds"
[23:20:46] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:46] [debug] AMX backtrace:
[23:20:46] [debug] #0 0036e074 in ?? (... <2 arguments>) at asd.pwn:41390
[23:20:46] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:46] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:46] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:46] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:47] [debug] Run time error 4: "Array index out of bounds"
[23:20:47] [debug]  Attempted to read/write array element at index 1110704128 in array of size 200
[23:20:47] [debug] AMX backtrace:
[23:20:47] [debug] #0 00371858 in ?? (... <2 arguments>) at asd.pwn:41711
[23:20:47] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:47] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:47] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:47] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:48] [debug] Run time error 4: "Array index out of bounds"
[23:20:48] [debug]  Attempted to read/write array element at index 1110704128 in array of size 200
[23:20:48] [debug] AMX backtrace:
[23:20:48] [debug] #0 000f56e4 in ?? (... <2 arguments>) at asd.pwn:17517
[23:20:48] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:48] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:48] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:48] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:49] [debug] Run time error 4: "Array index out of bounds"
[23:20:49] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:49] [debug] AMX backtrace:
[23:20:49] [debug] #0 003939b4 in ?? (... <2 arguments>) at asd.pwn:44735
[23:20:49] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:49] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:49] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:49] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:52] [debug] Run time error 4: "Array index out of bounds"
[23:20:52] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:52] [debug] AMX backtrace:
[23:20:52] [debug] #0 00372f18 in ?? (... <2 arguments>) at asd.pwn:41803
[23:20:52] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:52] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:52] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:52] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:53] [debug] Run time error 4: "Array index out of bounds"
[23:20:53] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:53] [debug] AMX backtrace:
[23:20:53] [debug] #0 0038c94c in ?? (... <2 arguments>) at asd.pwn:44090
[23:20:53] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:53] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:53] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:53] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:54] [debug] Run time error 4: "Array index out of bounds"
[23:20:54] [debug]  Attempted to read/write array element at index 1110704128 in array of size 2000
[23:20:54] [debug] AMX backtrace:
[23:20:54] [debug] #0 0038c6a0 in ?? (... <2 arguments>) at asd.pwn:44077
[23:20:54] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:54] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:54] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:54] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:56] [debug] Run time error 4: "Array index out of bounds"
[23:20:56] [debug]  Attempted to read/write array element at index 1110704128 in array of size 2000
[23:20:56] [debug] AMX backtrace:
[23:20:56] [debug] #0 0038c3b8 in ?? (... <2 arguments>) at asd.pwn:44063
[23:20:56] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:56] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:56] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:56] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:57] [debug] Run time error 4: "Array index out of bounds"
[23:20:57] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:57] [debug] AMX backtrace:
[23:20:57] [debug] #0 003922f0 in ?? (... <2 arguments>) at asd.pwn:44623
[23:20:57] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:57] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:57] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:57] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=14) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
[23:20:59] AdmWarning: Maya Diab was banned for an unauthorized RCON login.
[23:20:59] [debug] Run time error 4: "Array index out of bounds"
[23:20:59] [debug]  Attempted to read/write array element at index 1110704128 in array of size 201
[23:20:59] [debug] AMX backtrace:
[23:20:59] [debug] #0 00385230 in ?? (... <2 arguments>) at asd.pwn:43475
[23:20:59] [debug] #1 00047bb0 in public MP_OPCPTD () at D:\PAWN Scripting\Royal Life\pawno\include\YSI\y_hooks/impl.inc:2890
[23:20:59] [debug] #2 native CallLocalFunction () from samp03svr
[23:20:59] [debug] #3 000375b4 in public SM_OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=13) at D:\PAWN Scripting\Royal Life\pawno\include\mSelection.inc:491
[23:20:59] [debug] #4 00034be0 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText:playertextid=13) at D:\PAWN Scripting\Royal Life\pawno\include\selection.inc:444
The lines in the logs aren't even related to the system, idk why are they mentioned there.. tell me if you need a specific line.
Reply
#2

The problem is in a function that is called in `OnPlayerClickPlayerTextDraw` callback. The only time I have seen indexes this high is when using `random` function with value smaller than 1.
Reply
#3

Would much "else if" cause this problem too?
Reply
#4

There is only ever one error the first error. This is such an easy problem to fix there is a tutorial on this somewhere but I can't find it for some reason. Anyone else find it?
Reply
#5

bump
Reply
#6

So, after some inspection i believe these two parts may be the parts which cause the errors as when the player uses it he gets a ban by the server for "Unauthorized RCON login" which is a system implemented by me to ban anyone who tries to login to the rcon while not an admin.

PHP Code:
else if(playertextid == ageplus[playerid])
    {
        if(
playerdone[playerid] != 0) return SendClientMessage(playeridCOLOR_LIGHTRED"ERROR: You've already saved your progress, click reset if you want to edit something.");
        if(
playerage[playerid] < 99)
        {
            new 
agevalue[2], yearvalue[3];
            
playerage[playerid] = playerage[playerid]+1;
            
valstr(agevalueplayerage[playerid]);
            
PlayerTextDrawHide(playeridregistrationtextdraw_40[playerid]);
            
PlayerTextDrawSetString(playeridregistrationtextdraw_40[playerid], agevalue);
            
PlayerTextDrawShow(playeridregistrationtextdraw_40[playerid]);
            
valstr(yearvalue2019-playerage[playerid]);
            
PlayerTextDrawHide(playeridyears[playerid]);
            
PlayerTextDrawSetString(playeridyears[playerid], yearvalue);
            
PlayerTextDrawShow(playeridyears[playerid]);
        } else return 
0;
    }
    else if(
playertextid == ageminus[playerid])
    {
        if(
playerdone[playerid] != 0) return SendClientMessage(playeridCOLOR_LIGHTRED"ERROR: You've already saved your progress, click reset if you want to edit something.");
        if(
playerage[playerid] > 15)
        {
            new 
agevalue[1], yearvalue[3];
            
playerage[playerid] = playerage[playerid]-1;
            
valstr(agevalueplayerage[playerid]);
            
PlayerTextDrawHide(playeridregistrationtextdraw_40[playerid]);
            
PlayerTextDrawSetString(playeridregistrationtextdraw_40[playerid], agevalue);
            
PlayerTextDrawShow(playeridregistrationtextdraw_40[playerid]);
            
valstr(yearvalue2019-playerage[playerid]);
            
PlayerTextDrawHide(playeridyears[playerid]);
            
PlayerTextDrawSetString(playeridyears[playerid], yearvalue);
            
PlayerTextDrawShow(playeridyears[playerid]);
        } else return 
0;
    } 
Reply
#7

Do i really have to bump so much?
Reply
#8

bump..
Reply
#9

bump
Reply
#10

The problem is so trivial really one of the most common and easiest to fix. Start putting in printf's and validate your data and trace the sources.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)