Ping Kick problem.
#1

I have one problem about this:
Error:
Code:
[16:30:24] [debug] AMX backtrace:
[16:30:24] [debug] #0 000b475c in public PingKick () from codww.amx
[16:31:19] [debug] Run time error 4: "Array index out of bounds"
[16:31:19] [debug]  Accessing element at index 4 past array upper bound 3
Code:
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 | Max Allowed %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;
			}
		}
	}
Thanks.
Reply
#2

change
pawn Code:
PingPos++; if(PingPos > PING_MAX_EXCEEDS) PingPos = 0;
to

pawn Code:
++PingPos;
PingPos %= PING_MAX_EXCEEDS;
Reply
#3

Thank you. +REP
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)