Accessing element at index 11 past array upper bound 4
#1

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.
Reply
#2

How did you declared this variable: FactionData?
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)