Run time error 4: "Array index out of bounds"
#1

Help me with this error please I don't know what is wrong :

[01:01:58] [npc:join] Zombie_0 has joined the server (398:127.0.0.1)
[01:01:58] [npc:join] Zombie_1 has joined the server (397:127.0.0.1)
[01:01:58] [npc:join] Zombie_2 has joined the server (396:127.0.0.1)
[01:01:58] [npc:join] Zombie_3 has joined the server (395:127.0.0.1)
[01:01:58] [npc:join] Zombie_4 has joined the server (394:127.0.0.1)
[01:01:58] [npc:join] Zombie_5 has joined the server (393:127.0.0.1)
[01:01:58] [npc:join] Zombie_6 has joined the server (392:127.0.0.1)
[01:01:58] [npc:join] Zombie_7 has joined the server (391:127.0.0.1)
[01:01:58] [npc:join] Zombie_8 has joined the server (390:127.0.0.1)
[01:01:58] [npc:join] Zombie_9 has joined the server (389:127.0.0.1)
[01:01:58] [npc:join] Zombie_10 has joined the server (388:127.0.0.1)
[01:01:58] [npc:join] Zombie_11 has joined the server (387:127.0.0.1)
[01:01:58] [npcart] Zombie_11 has left the server (387:2)
[01:01:58] [debug] Run time error 4: "Array index out of bounds"
[01:01:58] [debug] Accessing element at index 387 past array upper bound 324
[01:01:58] [FCNPC] Error: NPC 'Zombie_11' not created. Name 'Zombie_11' is invalid or the maxnpc limit in server.cfg has been reached.
[01:01:58] [debug] Run time error 4: "Array index out of bounds"
[01:01:58] [debug] Accessing element at index 65535 past array upper bound 398
[01:01:58] [debug] AMX backtrace:
[01:01:58] [debug] #0 003fb970 in crearBarraSalud (npcid=65535) at x\x.pwn:65690

Line 65690: labelZombies[npcid] = Create3DTextLabel(string, -1, 0, 0, 0, 100.0, 0, 1);

Код:
stock crearZombies()
{
	new name[MAX_PLAYER_NAME + 1 ];
	for(new i = 0; i<MAX_ZOMBIES; i++)
	{
		format(name, sizeof(name), "Zombie_%d", i);
		crearZombie(name);
	}

}
Код:
#define MAX_ZOMBIES 300
#undef 	MAX_PLAYERS
#define MAX_PLAYERS MAX_ZOMBIES+99
and on my server.cfg I have this:

Quote:

maxplayers 399

maxnpc 399

So I don't know where is the error
Reply
#2

So Zombie 11 crashes, then the array is accessing an invalid ID as the NPC already disconnected, so you need to figure out why the NPC is falling off.


Also be sure, when using crashdetect, to use -d3 in the compile options.



Actually, have a real hard look around in this, is there possibly 2 arrays that are OOBing? One refers to upper limit of 324, whilst the other refers to upper limit 398.
Reply
#3

Sorry for delay in answer , well there is the complete log compiled with -d3 flag

Quote:

[01:01:58] [npc:join] Zombie_0 has joined the server (398:127.0.0.1)
[01:01:58] [npc:join] Zombie_1 has joined the server (397:127.0.0.1)
[01:01:58] [npc:join] Zombie_2 has joined the server (396:127.0.0.1)
[01:01:58] [npc:join] Zombie_3 has joined the server (395:127.0.0.1)
[01:01:58] [npc:join] Zombie_4 has joined the server (394:127.0.0.1)
[01:01:58] [npc:join] Zombie_5 has joined the server (393:127.0.0.1)
[01:01:58] [npc:join] Zombie_6 has joined the server (392:127.0.0.1)
[01:01:58] [npc:join] Zombie_7 has joined the server (391:127.0.0.1)
[01:01:58] [npc:join] Zombie_8 has joined the server (390:127.0.0.1)
[01:01:58] [npc:join] Zombie_9 has joined the server (389:127.0.0.1)
[01:01:58] [npc:join] Zombie_10 has joined the server (388:127.0.0.1)
[01:01:58] [npc:join] Zombie_11 has joined the server (387:127.0.0.1)
[01:01:58] [npcart] Zombie_11 has left the server (387:2)
[01:01:58] [debug] Run time error 4: "Array index out of bounds"
[01:01:58] [debug] Accessing element at index 387 past array upper bound 324
[01:01:58] [debug] AMX backtrace:
[01:01:58] [debug] #0 0006b184 in public BustAim_OnPlayerConnect (playerid=387) at C:\Users\x.pwn:6304
[01:01:58] [debug] #1 000446c0 in public FC_OnPlayerConnect (playerid=387) at C:\Users\x\include\antiaimbotZ.inc:655
[01:01:58] [debug] #2 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #3 00040348 in public AB_OnPlayerConnect (playerid=387) at C:\Users\x\include\floodcontrol.inc:68
[01:01:58] [debug] #4 0003d0c4 in public MP_OPC (playerid=387) at C:\Users\x\include\e_airbreak.inc:36
[01:01:58] [debug] #5 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #6 0003589c in ?? (... <1 argument>) at C:\Users\x\include\mSelection.inc:432
[01:01:58] [debug] #7 00022030 in public SSCANF_OnPlayerConnect (playerid=387) at C:\Usersx\include\YSI\y_hooks/impl.inc:618
[01:01:58] [debug] #8 0000de24 in public Itter_OnPlayerConnect (playerid=387) at C:\Users\x\include\sscanf2.inc:236
[01:01:58] [debug] #9 0000b55c in public OnPlayerConnect (playerid=387) at C:\x\include\YSI\y_iterate.inc:646
[01:01:58] [debug] #10 native FCNPC_Create () from FCNPC.so
[01:01:58] [debug] #11 003f96e4 in crearZombie (name[]=@0307c030 "Zombie_11") at C:\Users\x.pwn:65408
[01:01:58] [debug] #12 003f9684 in crearZombies () at C:\Users\x.pwn:65400
[01:01:58] [debug] #13 000c47ec in public zcmd_OnGameModeInit () at C:\Users\x.pwn:11309
[01:01:58] [debug] #14 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #15 00031a90 in public fcnpc1_OnGameModeInit () at C:\x\include\zcmd.inc:68
[01:01:58] [debug] #16 0003188c in public fcnpc0_OnGameModeInit () at C:\x\include\FCNPC.inc:556
[01:01:58] [debug] #17 00031420 in ?? () at C:\Users\x\FCNPC.inc:453
[01:01:58] [debug] #18 00021c50 in public SSCANF_OnGameModeInit () at C:\Users\x\include\YSI\y_hooks/impl.inc:484
[01:01:58] [debug] #19 0000dd30 in public Itter_OnGameModeInit () at C:\Users\x\include\sscanf2.inc:205
[01:01:58] [debug] #20 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #21 0000ba28 in public ScriptInit_OnGameModeInit () at C:\Users\x\include\YSI\y_iterate.inc:791
[01:01:58] [debug] #22 0000aa30 in public OnGameModeInit () at C:\Users\x\include\YSI\internal\..\y_scriptinit.in c:171
[01:01:58] [FCNPC] Error: NPC 'Zombie_11' not created. Name 'Zombie_11' is invalid or the maxnpc limit in server.cfg has been reached.
[01:01:58] [debug] Run time error 4: "Array index out of bounds"
[01:01:58] [debug] Accessing element at index 65535 past array upper bound 398
[01:01:58] [debug] AMX backtrace:
[01:01:58] [debug] #0 003fb970 in crearBarraSalud (npcid=65535) at C:\x.pwn:65690
[01:01:58] [debug] #1 003f9768 in crearZombie (name[]=@0307c030 "Zombie_11") at C:\Users\x.pwn:65412
[01:01:58] [debug] #2 003f9684 in crearZombies () at C:\Users\Bx.pwn:65400
[01:01:58] [debug] #3 000c47ec in public zcmd_OnGameModeInit () at C:\x.pwn:11309
[01:01:58] [debug] #4 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #5 00031a90 in public fcnpc1_OnGameModeInit () at C:\Users\x\include\zcmd.inc:68
[01:01:58] [debug] #6 0003188c in public fcnpc0_OnGameModeInit () at C:\x\include\FCNPC.inc:556
[01:01:58] [debug] #7 00031420 in ?? () at C:\x\include\FCNPC.inc:453
[01:01:58] [debug] #8 00021c50 in public SSCANF_OnGameModeInit () at C:\x\include\YSI\y_hooks/impl.inc:484
[01:01:58] [debug] #9 0000dd30 in public Itter_OnGameModeInit () at C:\Users\x\include\sscanf2.inc:205
[01:01:58] [debug] #10 native CallLocalFunction () from samp03svr
[01:01:58] [debug] #11 0000ba28 in public ScriptInit_OnGameModeInit () at C:\Users\x\include\YSI\y_iterate.inc:791
[01:01:58] [debug] #12 0000aa30 in public OnGameModeInit () at C:\Users\x\include\YSI\internal\..\y_scriptinit.in c:171

I think this part of the code is causing the bug because I can't have 400 players or more (only up to 399)

Код:
if(Iter_Count(Player) > MaxPlayersConnected)
	{
		MaxPlayersConnected = Iter_Count(Player);
		gettime(MPHour,MPMinute);
		getdate(MPYear,MPMonth,MPDay);
	}
	if(MaxPlayersConnected > 400) MaxPlayersConnected = 400; // Temp good fix

	new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	if(!INI_Exist(playername)) // If exists in Y_ini
	{
    	if(doesAccountExist(playername)) // If exists in .ini
    	{
			ConvertAccount(playerid); // Convert Account to y_ini
			return 1;
		}
	}
	SetTimerEx("SafeLogin", 4000, 0, "d", playerid);
 	return 1;}
Reply
#4

Just on a side note, you should re-arrange your includes/files...

Код:
C:\Users\x.pwn
C:\Users\x\include\floodcontrol.inc
C:\x\include\zcmd.inc
C:\Usersx\include\YSI\y_hooks/impl.inc
Having all of this everywhere makes things confusing and hard to keep track of for yourself.

Did it work at all, and it's simply started not working?

When it started happening, what had you done? Like, say a week or so prior, what were you working on?
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Just on a side note, you should re-arrange your includes/files...

Код:
C:\Users\x.pwn
C:\Users\x\include\floodcontrol.inc
C:\x\include\zcmd.inc
C:\Usersx\include\YSI\y_hooks/impl.inc
Having all of this everywhere makes things confusing and hard to keep track of for yourself.

Did it work at all, and it's simply started not working?

When it started happening, what had you done? Like, say a week or so prior, what were you working on?
Ooo Sorry I had to say it , I'm trying to add bots to my server with the plugin FCNPC , so when I try to charge them , this bug appears , but when I run the gamemode without the bot's it runs properly:

Works Ok (Without bots):

Код:
#undef 	MAX_PLAYERS
#define MAX_PLAYERS 399

public OnGameModeInit()
{
//crearZombies();
Don't work (Trying to add bots):

Код:
#define MAX_ZOMBIES 300 
#undef 	MAX_PLAYERS
#define MAX_PLAYERS	MAX_ZOMBIES+99

public OnGameModeInit()
{
crearZombies();
Reply
#6

Ah, so this hasn't broken as such, it's an error somewhere that's always been.

Which version are you using? Ziggis?


I have't used FCNPCs before, but this shouldn't stop like this for no reason. Looking over the release thread it doesn't seem there's a config file or a setting you're missing. Someone surely will know what could be happening, so sit tight on this thread.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Ah, so this hasn't broken as such, it's an error somewhere that's always been.

Which version are you using? Ziggis?


I have't used FCNPCs before, but this shouldn't stop like this for no reason. Looking over the release thread it doesn't seem there's a config file or a setting you're missing. Someone surely will know what could be happening, so sit tight on this thread.
I'm using 1.8.2 FCNPC version , Thanks for your help you gave me a idea , I'm trying to update my all includes maybe the problem is there also I'm checking Ysi_Ac, Ysi_Coding etc...... I will be playing with this meanwhile , thanks :P
Reply
#8

Good stuff, Keep on trucking
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)