[debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] - 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: [debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] (
/showthread.php?tid=513196)
[debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] -
Trynda - 15.05.2014
Hello, I added this
Код:
new cdveh = GetPlayerVehicleID(MAX_PLAYERS);
if(GetCarDealershipVehicleId(cdveh) != -1 && GetCarDealershipVehicleId(cdveh) == GetPVarInt(playerid, "editingcdveh")) return 1;
if(GetCarDealershipVehicleId(cdveh) != -1)
{
new string[128];
//new string[57 + 20 + 4];
format(string, sizeof(string),"Would you like to buy this %s? This vehicle costs $%d.", GetVehicleName(cdveh), CarDealershipInfo[GetCarDealershipId(cdveh)][cdVehicleCost][GetCarDealershipVehicleId(cdveh)]);
//ShowPlayerDialogEx(playerid,DIALOG_CDBUY,DIALOG_STYLE_MSGBOX,"Warning:",string,"Buy","Cancel");
SendClientMessage(playerid, COLOR_REALRED, string);
SendClientMessage(playerid, COLOR_YELLOW, "Type /buyvehicle to buy the car");
TogglePlayerControllable(playerid, false);
return 1;
}
And those messages doesnt appear. I tried to add the crashdetect plugin and i figure out the problem. Is caming from that line (im very sure)
How do i fix it
Thanks
Full Debug Error
Код:
[15/05/2014 15:14:07] [debug] Run time error 4: "Array index out of bounds"
[15/05/2014 15:14:07] [debug] Accessing element at negative index -400
[15/05/2014 15:14:07] [debug] AMX backtrace:
[15/05/2014 15:14:07] [debug] #0 002641b4 in public OnPlayerStateChange (0x00000000, 0x00000002, 0x00000001) from PHRP_1.5.amx
Just a note: Before i add that everything is fine no debug errors after i add it appears.
Respectfully yours,
Re: [debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] -
VishvaJeet - 15.05.2014
OnPlayerEnterDynamicCP or any CMD
what is that function ?
Re: [debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] -
Vince - 15.05.2014
Quote:
Originally Posted by Trynda
Hello, I added this
Код:
new cdveh = GetPlayerVehicleID(MAX_PLAYERS);
|
What the hell is this? What are you trying to do?
Re: [debug] Run time error 4: "Array index out of bounds" [READ FOR MORE INFO] -
Konstantinos - 15.05.2014
Because you did:
pawn Код:
new cdveh = GetPlayerVehicleID(MAX_PLAYERS);
when it should be "playerid" instead of "MAX_PLAYERS" and cdveh is 0 and then using:
will cause the run time error because you basically do: 0-400 which results to a negative index. You must check if the modelid is not 0 and subtract.