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: Array index out of bounds. (
/showthread.php?tid=663558)
Array index out of bounds. -
Kortecs - 04.02.2019
Problem: When i log in my account after the server kick me.
[debug] Accessing element at index 270 past array upper bound 68
[debug] AMX backtrace:
[debug] #0 0017dd34 in public PassCheck (0) from aaa.amx
What wrong is in that public?
https://pastebin.com/Q7sF59wH
Re: Array index out of bounds. -
Calisthenics - 04.02.2019
One of these:
Код:
format(szMessage, sizeof(szMessage), "(Group) MOTD: "EMBED_WHITE"%s", groupVariables[playerVariables[extraid][pGroup]][gGroupMOTD]);
format(string,256,"%s%s",clanVariables[playerVariables[extraid][pClan]][cClanTag],playerVariables[extraid][pNormalName]);
format(string,256,"%s%s",playerVariables[extraid][pNormalName],clanVariables[playerVariables[extraid][pClan]][cClanTag]);
It checks if group or clan is >= 1 only. Checking the upper bound will prevent the run time error:
pawn Код:
if(playerVariables[extraid][pGroup] >= 1 && playerVariables[extraid][pGroup] < sizeof (groupVariables))
// and
if(playerVariables[extraid][pClan] >= 1 && playerVariables[extraid][pClan] < sizeof (clanVariables))
but it might be logical error. What I mean is there are 68 groups or clans defined and the group or clan sql id is 270. Find the array index and use that, not the sql id.