CrashDetect - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CrashDetect (
/showthread.php?tid=496569)
CrashDetect -
SPA - 22.02.2014
Код:
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(grey,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;
}
}
}
#if defined ANTI_MINIGUN
new weap, ammo;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][Level] == 0)
{
GetPlayerWeaponData(i, 7, weap, ammo);
if(ammo > 1 && weap == 38) {
new string[128]; format(string,sizeof(string),"INFO: %s has a mingun with %d ammo", PlayerName2(i), ammo);
MessageToAdmins(COLOR_WHITE,string);
}
}
}
#endif
}
Код:
[[09:10:45]+ [debug] #0 000a5be0 in public PingKick () at C:\Users\MaHdy\Desktop\SPA Test\filterscripts\ladmin.pwn:8215
[09:11:14]+ [debug] Run time error 4: "Array index out of bounds"
[09:11:14]+ [debug] Accessing element at index 4 past array upper bound 3
[09:11:14]+ [debug] AMX backtrace:
[09:11:14]+ [debug] #0 000a5be0 in public PingKick () at C:\Users\MaHdy\Desktop\SPA Test\filterscripts\ladmin.pwn:8215
LINE: 8215: PlayerInfo[i][pPing][PingPos] = GetPlayerPing(i);
Re: CrashDetect -
Konstantinos - 22.02.2014
It seems (to me) that you've defined MAX_PLAYERS as 5 and the PlayerInfo has size of 4. So when you loop and i is 4, it causes the run time error because the last valid bound is 3.
Re: CrashDetect -
SPA - 23.02.2014
What to do ?
Re: CrashDetect -
Konstantinos - 23.02.2014
First of all, let's make sure this is the correct code because it'd be very odd. Is the code you posted from ladmin filterscript or other script? We need the line 8215 from ladmin.pwn
If the code you've posted is from the correct file, then all you need to use is change the size from PlayerInfo array to MAX_PLAYERS.