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

error
Код:
[01:51:37] [debug] Run time error 4: "Array index out of bounds"
[01:51:37] [debug]  Accessing element at index 4 past array upper bound 3
[01:51:37] [debug] AMX backtrace:
[01:51:37] [debug] #0 00118d74 in public PingKick () from codww.amx
[01:52:03] [connection] 117.243.182.73:26861 requests connection cookie.
[01:52:05] [connection] incoming connection: 117.243.182.73:26861 id: 0
[01:52:09] Invalid client connecting from 117.243.182.73
[01:52:30] [debug] Run time error 4: "Array index out of bounds"
[01:52:30] [debug]  Accessing element at index 4 past array upper bound 3
[01:52:30] [debug] AMX backtrace:
[01:52:30] [debug] #0 00118d74 in public PingKick () from codww.amx
[01:52:35] Kicking 117.243.182.73 because they didn't logon to the game.
Code
Код:
forward PingKick();
public PingKick()
{
	if(ServerInfo[MaxPing] != 0)
	{
	    PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;

		for(new i=0; i<MAX_PLAYERS; i++)
		{
			PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);

		    if(GetPlayerPing(i) > ServerInfo[MaxPing])
			{
				if(PlayerInfo[i][PingCount] == 0) PlayerInfo[i][PingTime] = TimeStamp();

	   			PlayerInfo[i][PingCount]++;
				if(TimeStamp() - PlayerInfo[i][PingTime] > PING_TIMELIMIT)
				{
	    			PlayerInfo[i][PingTime] = TimeStamp();
					PlayerInfo[i][PingCount] = 1;
				}
				else if(PlayerInfo[i][PingCount] >= PING_MAX_EXCEEDS)
				{
				    new Sum, x, string[128];
					while (x < PING_MAX_EXCEEDS) {
						Sum += PlayerInfo[i][pPing][x];
						x++;
					}
					format(string,sizeof(string),"%s has been kicked from the server. [Reason: High Ping %d/%d]", PlayerName2(i), GetPlayerPing(i), ServerInfo[MaxPing] );
  		    		SendClientMessageToAll(red,string);
					SaveToFile("KickLog",string);
					Kick(i);
				}
			}
			else if(GetPlayerPing(i) < 1 && ServerInfo[AntiBot] == 1)
		    {
				PlayerInfo[i][BotPing]++;
				if(PlayerInfo[i][BotPing] >= 3) BotCheck(i);
		    }
		    else
			{
				PlayerInfo[i][BotPing] = 0;
			}
		}
	}
Reply
#2

Try using debug level 3, so it shows you the exact lines that produce the crash.
If you don't know how to do that, here's how:
You should create a file called pawn.cfg in your pawno folder, inside this file write:

PHP код:
-d3 
Save the file and recompile your script and run it with crashdetect again.
Reply
#3

Ok let i
Reply
#4

It Gives Me This In Server Log
Код:
[11:47:26] [debug] Run time error 4: "Array index out of bounds"
[11:47:26] [debug]  Accessing element at index 4 past array upper bound 3
[11:47:26] [debug] AMX backtrace:
[11:47:26] [debug] #0 00161820 in public PingKick () at C:\Users\Anurag\Desktop\Call of Duty black Ops 2 Script\gamemodes\codww.pwn:17435
Line
Код:
17425
Код:
PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);
Full Code With Line Highlighted
Код:
forward PingKick();
public PingKick()
{
	if(ServerInfo[MaxPing] != 0)
	{
	    PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;

		for(new i=0; i<MAX_PLAYERS; i++)
		{
			PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);

		    if(GetPlayerPing(i) > ServerInfo[MaxPing])
			{
				if(PlayerInfo[i][PingCount] == 0) PlayerInfo[i][PingTime] = TimeStamp();

	   			PlayerInfo[i][PingCount]++;
				if(TimeStamp() - PlayerInfo[i][PingTime] > PING_TIMELIMIT)
				{
	    			PlayerInfo[i][PingTime] = TimeStamp();
					PlayerInfo[i][PingCount] = 1;
				}
				else if(PlayerInfo[i][PingCount] >= PING_MAX_EXCEEDS)
				{
				    new Sum, x, string[128];
					while (x < PING_MAX_EXCEEDS) {
						Sum += PlayerInfo[i][pPing][x];
						x++;
					}
					format(string,sizeof(string),"%s has been kicked from the server. [Reason: High Ping %d/%d]", PlayerName2(i), GetPlayerPing(i), ServerInfo[MaxPing] );
  		    		SendClientMessageToAll(red,string);
					SaveToFile("KickLog",string);
					Kick(i);
				}
			}
			else if(GetPlayerPing(i) < 1 && ServerInfo[AntiBot] == 1)
		    {
				PlayerInfo[i][BotPing]++;
				if(PlayerInfo[i][BotPing] >= 3) BotCheck(i);
		    }
		    else
			{
				PlayerInfo[i][BotPing] = 0;
			}
		}
	}
Reply
#5

Try to checking IsPlayerConnected() before everything in the for loop.
Reply
#6

http://forum.sa-mp.com/showpost.php?...9&postcount=11

or

http://forum.sa-mp.com/showpost.php?...69&postcount=2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)