Run time error 4: "Array index out of bounds" - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Run time error 4: "Array index out of bounds" (
/showthread.php?tid=424762)
Run time error 4: "Array index out of bounds" -
shady001 - 23.03.2013
I have 2 hours since i'm trying to solve this , i think i'm going crazy ...
I have :
pawn Код:
new Text3D:fEnter[17];
enum Factions
{
fName[50],
fLeader[MAX_PLAYER_NAME],
Float:fX,
Float:fY,
Float:fZ,
fMats,
fDrugs,
fBank,
fMembers,
fWar
};
new sFactions[17][Factions];
//ongamemodeinit
for(new f = 0;f<=sizeof(sFactions);f++)
{
new stringf[256];
format(stringf,sizeof(stringf),"{FFFF00}%s\n{FF0000}Leader:%s\n",sFactions[f][fName],sFactions[f][fLeader]); // 11756
if(f == 1)
{
fEnter[f] = Create3DTextLabel(stringf,RED,sFactions[f][fX],sFactions[f][fY],sFactions[f][fZ],15,-1,1);
}
else if(f<=16){
fEnter[f] = Create3DTextLabel(stringf,RED,sFactions[f][fX],sFactions[f][fY],sFactions[f][fZ],15,-1,1);
AddStaticPickup(19198, 23, sFactions[f][fX],sFactions[f][fY],sFactions[f][fZ]);
}
}
And the error:
pawn Код:
[19:21:49] [debug] Run time error 4: "Array index out of bounds"
[19:21:49] [debug] Accessing element at index 16 past array upper bound 15
[19:21:49] [debug] AMX backtrace:
[19:21:49] [debug] #0 0008e7e8 in public OnGameModeInit () at shady.pwn:11756
I have modify fEnter to 18... 20 nothing ... modify the sFactions to 16 15 still nothing ...
Please some help
Re: Run time error 4: "Array index out of bounds" -
Konstantinos - 23.03.2013
Change to
pawn Код:
for(new f = 0;f<sizeof(sFactions);f++)
The max value an index can access is 16, not 17 according to your factions.
Re: Run time error 4: "Array index out of bounds" -
shady001 - 23.03.2013
Ok , that worked , thanks . But now i don't know why when i start my server it stopped responding ... And on my log is no error... Any ideas what can cause this ? (I have already commented all the work i have done since it worked last time) (The server was crashing when i posted that error , i thought that is from that error but it seams it is not

)
EDIT: server crash have been solved with a PC restart ... Thanks