Crash - 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: Crash (
/showthread.php?tid=651250)
Crash -
Hunud - 16.03.2018
Server is crashing. I have this in logs.
Logs:
Код:
[20:48:25] [debug] Run time error 4: "Array index out of bounds"
[20:48:25] [debug] AMX backtrace:
[20:48:25] [debug] #0 00092cb8 in public GivePlayerMoneyEx (65535, 2500) from CnR.amx
Code:
Код:
public GivePlayerMoneyEx(playerid,ammount)
{
OldMoney[playerid] = GetPlayerMoney(playerid);
NewMoney[playerid] = ammount + OldMoney[playerid];
GivePlayerMoney(playerid,ammount);
return 1;
}
Re: Crash -
AdamsLT - 16.03.2018
I think some piece of code is sending an invalid player id to the function, which crashes it.
Quote:
[20:48:25] [debug] #0 00092cb8 in public GivePlayerMoneyEx (65535, 2500) from CnR.amx
|
Search for something that gives a player 2500 cash, either post that code here for further help or try to add a check if the playerid is INVALID_PLAYER_ID and then stop the code before it does anything.
Re: Crash -
Abagail - 17.03.2018
For more detailed reporting, you can #include crashdetect while compiling and also compile with the -d3 flag. Regardless, your issue is this:
65535 is the definition for INVALID_PLAYER_ID, which is what is being passed to this function. Because OldMoney and NewMoney likely only go up to MAX_PLAYERS, this causes it to attempt to access data out of range.
First you need to figure out why it is being called with INVALID_PLAYER_ID, and secondly, you can add an IsPlayerConnected check (although that is a workaround and doesn't explain why it is being called in the first place) at the top of the function and stop further execution through returning 0 if not connected.