PDA

View Full Version : error random pingkick


nbx2000
21/06/2019, 11:53 PM
helpme
[05:08:47] [debug] Run time error 4: "Array index out of bounds"
[05:08:47] [debug] Accessing element at index 4 past array upper bound 3
[05:08:47] [debug] AMX backtrace:
[05:08:47] [debug] #0 001347b4 in public PingKick () from Test.amx

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, Average, x, string[128];
while (x < PING_MAX_EXCEEDS) {
Sum += PlayerInfo[i][pPing][x];
x++;
}
Average = (Sum / PING_MAX_EXCEEDS);
format(string,sizeof(string),"%s has been kicked from the server. (Reason: High Ping (%d) | Average (%d) | Max Allowed (%d) )", PlayerName2(i), GetPlayerPing(i), Average, ServerInfo[MaxPing] );
SendClientMessageToAll(ckicked,string);
Kick(i);
}
}
}
}
}

Mugala
25/06/2019, 10:47 AM
change string[128]; to string[300]; if a problem still appears, show me what is MaxPing in ServerInfo array.