[SOLVED] Run time error 4: "Array index out of bounds -
R3SpaWn0 - 01.08.2018
EDIT: Solved, it was becouse in OnPlayerExit i have SaveCar and SaveCharacter, and i was using Temporal Veh /veh, and when the scripts want to go save the veh coordinates in database say error becouse the vehicle dont really exist in database, its temporal ! I fixed it with brain and:
Code:
if (CoreVehicles[vehicleid][vehTemporary])
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Server tried to save coordinates of this temporary car but it's not existing, now it's not causing bug !!");
return 1;
}
Now i go to create the /savecar cmd

to insert to database
Hi, i m running my script and its running perfect, but i was testing with a friend and i saw i got in console this, and then server i think reboot..
Code:
[20:21:12] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000001, 0x0000000e) from roleplay.amx
[20:21:39] [debug] Run time error 4: "Array index out of bounds"
[20:21:39] [debug] Accessing element at negative index -1
[20:21:39] [debug] AMX backtrace:
[20:21:39] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000001, 0x0000000e) from roleplay.amx
[20:23:48] [debug] Run time error 4: "Array index out of bounds"
[20:23:48] [debug] Accessing element at negative index -1
[20:23:48] [debug] AMX backtrace:
[20:23:48] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000000, 0x0000000e) from roleplay.amx
[20:23:50] [debug] Run time error 4: "Array index out of bounds"
[20:23:50] [debug] Accessing element at negative index -1
[20:23:50] [debug] AMX backtrace:
[20:23:50] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000001, 0x0000000e) from roleplay.amx
[20:25:39] [debug] Run time error 4: "Array index out of bounds"
[20:25:39] [debug] Accessing element at negative index -1
[20:25:39] [debug] AMX backtrace:
[20:25:39] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000000, 0x0000000e) from roleplay.amx
[20:25:43] [debug] Run time error 4: "Array index out of bounds"
[20:25:43] [debug] Accessing element at negative index -1
[20:25:43] [debug] AMX backtrace:
[20:25:43] [debug] #0 000b8c30 in public OnPlayerExitVehicle (0x00000001, 0x0000000e) from roleplay.amx
[20:25:43] [debug] Run time error 4: "Array index out of bounds"
[20:25:43] [debug] Accessing element at negative index -1
[20:25:43] [debug] AMX backtrace:
I show you OnPlayerExitVehicle
PHP Code:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if (IsPlayerNPC(playerid))
return 1;
if (PlayerData[playerid][pTaxiDuty])
{
foreach (new i : Player) if (PlayerData[i][pTaxiPlayer] == playerid && IsPlayerInVehicle(i, GetPlayerVehicleID(playerid))) {
LeaveTaxi(i, playerid);
}
SetPlayerColor(playerid, DEFAULT_COLOR);
PlayerData[playerid][pTaxiDuty] = false;
SendServerMessage(playerid, "You are no longer on taxi duty!");
}
if (PlayerData[playerid][pDrivingTest])
{
SetTimerEx("PutInsideVehicle", 500, false, "dd", playerid, vehicleid);
Dialog_Show(playerid, LeaveTest, DIALOG_STYLE_MSGBOX, "Confirm Test Leave", "Warning: Are you sure you want to exit the driving test?", "Yes", "No");
}
if (PlayerData[playerid][pJob] == JOB_UNLOADER && GetVehicleModel(vehicleid) == 530)
{
CoreVehicles[vehicleid][vehLoadType] = 0;
DestroyObject(CoreVehicles[vehicleid][vehCrate]);
CoreVehicles[vehicleid][vehCrate] = INVALID_OBJECT_ID;
DisablePlayerCheckpoint(playerid);
}
new Float:x, Float:y, Float:z, Float:a;
new carid = Car_Nearest(playerid);
new id = Car_GetID(vehicleid);
new Float:vHealth;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, vHealth);
GetVehiclePos(vehicleid,x,y,z);
GetVehicleZAngle(vehicleid,a);
CarData[carid][carPos][0] = x;
CarData[carid][carPos][1] = y;
CarData[carid][carPos][2] = z;
CarData[carid][carPos][3] = a;
CarData[carid][carHealth] = vHealth;
Car_Save(id);
SQL_SaveCharacter(playerid);
return 1;
}
Is good to Car_Save and SaveCharacter on here? or maybe i make a timer with that? thank you !
Re: Run time error 4: "Array index out of bounds -
kingmk - 01.08.2018
Can u show us your Car_GetID(vehicleid) and Car_Nearest(playerid) function?
Re: Run time error 4: "Array index out of bounds -
R3SpaWn0 - 01.08.2018
PHP Code:
stock Car_GetID(vehicleid)
{
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++) if (CarData[i][carExists] && CarData[i][carVehicle] == vehicleid) {
return i;
}
return -1;
}
PHP Code:
Car_Nearest(playerid)
{
static
Float:fX,
Float:fY,
Float:fZ;
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++) if (CarData[i][carExists]) {
GetVehiclePos(CarData[i][carVehicle], fX, fY, fZ);
if (IsPlayerInRangeOfPoint(playerid, 3.0, fX, fY, fZ)) {
return i;
}
}
return -1;
}
here you have my friend
Re: Run time error 4: "Array index out of bounds -
R3SpaWn0 - 01.08.2018
Solved Guys, look at the top !