SA-MP Forums Archive
Anti Crash Fix Maybe? - 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: Anti Crash Fix Maybe? (/showthread.php?tid=463705)



Anti Crash Fix Maybe? - Roel - 13.09.2013

Hello,

Few minutes ago my server was crashing every 5-10 minutes.
I think this was caused by a hacker.
Anyway I have run the gamemode with crashdetect and this came out >

[16:38:45] [debug] Run time error 4: "Array index out of bounds"
[16:38:45] [debug] Accessing element at index 65535 past array upper bound 79
[16:38:45] [debug] AMX backtrace:
[16:38:45] [debug] #0 0005ceb4 in public OnPlayerTakeDamage () from x_gamemode.amx

Which means for some reason a playerid which was 65535 came into OnPlayerTakeDamage, and this caused the server to crash.
So I added ,

if(issuerid > MAX_PLAYERS || playerid > MAX_PLAYERS) return 0;

Under OnPlayerTakeDamage (at the top).

Im not sure if it has been fixed, but the server hasn't been crashed since so I guess it did.

So if someone can confirm that this is working then others can use it too, to prevent crashers.


Re: Anti Crash Fix Maybe? - PT - 13.09.2013

That code dont have logic i think that can't be possible


Re: Anti Crash Fix Maybe? - Konstantinos - 13.09.2013

You only need to check if issuerid is not INVALID_PLAYER_ID and then do your code inside that.


Re: Anti Crash Fix Maybe? - Kirollos - 13.09.2013

tried this?
pawn Код:
if(issuerid == INVALID_PLAYER_ID || playerid == INVALID_PLAYER_ID) return 1;
Because there is an array you have there with issuerid/playerid which is actually 65535 so it crashes.

pawn Код:
new var[5];

main() {
var[4] = 1; // Safe
var[10] = 1; // Crash
}



Re: Anti Crash Fix Maybe? - Konstantinos - 13.09.2013

@kirollos: No need to check for the playerid too. If the playerid was invalid, then the OnPlayerTakeDamage callback would not been called at all.


Re: Anti Crash Fix Maybe? - zrelly - 13.09.2013

Might be rak-samp bot lagging/crashing the server.