SA-MP Forums Archive
Accessing element at index 11 past array upper bound 4 - 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: Accessing element at index 11 past array upper bound 4 (/showthread.php?tid=368742)



[SOLVED] Accessing element at index 11 past array upper bound 4 - KuHS - 14.08.2012

I don't know how to fix this error. I've found it with crashdetect plugin.

Код:
[10:30:30] [debug] Run time error 4: "Array index out of bounds"
[10:30:30] [debug]  Accessing element at index 11 past array upper bound 4
[10:30:30] [debug] AMX backtrace:
[10:30:30] [debug] #0 0001a0b4 in GetFactionDescription (factionid=11) at rpg_data/system/faction.pwn:143
[10:30:30] [debug] #1 0001c298 in public cmd_darbas (playerid=0, params[]=@0x000149b4 "") at rpg_data/system/command.pwn:49
[10:30:30] [debug] #2 native CallLocalFunction () [00472c00] from samp-server.exe
[10:30:30] [debug] #3 00002170 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x00014994 "") at C:\Program Files (x86)\pawno\include\zcmd.inc:102
Script:
Код:
stock GetFactionDescription(factionid)
{
	new string[64];
	/*143 line*/ if(factionid == FACTION_MEDIC_ID)			format(string, 64, "%s\n...", FactionData[factionid][fName]);
	else if(factionid == FACTION_TAXI_ID)		format(string, 64, "%s\n...", FactionData[factionid][fName]);
	else if(factionid == FACTION_MECHANIC_ID)	format(string, 64, "%s\n...", FactionData[factionid][fName]);
	else if(factionid == FACTION_POLICE_ID)		format(string, 64, "%s\n...", FactionData[factionid][fName]);
	else if(factionid == FACTION_SWAT_ID)		format(string, 64, "%s\n...", FactionData[factionid][fName]);
	else                                        format(string, 64, "Error.");
	return string;
}
fName is array - fName[26];
FACTION_MEDIC_ID is define - value 11.

Thanks.


Re: Accessing element at index 11 past array upper bound 4 - Roko_foko - 14.08.2012

How did you declared this variable: FactionData?


Re: Accessing element at index 11 past array upper bound 4 - KuHS - 14.08.2012

Ahhh, thanks for the tip to check variables. Problem solved : )