Run time error 4: "Array index out of bounds
#1

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(playeridvehicleid)
{
    if (
IsPlayerNPC(playerid))
        return 
1;
    if (
PlayerData[playerid][pTaxiDuty])
    {
        foreach (new 
Player) if (PlayerData[i][pTaxiPlayer] == playerid && IsPlayerInVehicle(iGetPlayerVehicleID(playerid))) {
            
LeaveTaxi(iplayerid);
        }
        
SetPlayerColor(playeridDEFAULT_COLOR);
        
PlayerData[playerid][pTaxiDuty] = false;
        
SendServerMessage(playerid"You are no longer on taxi duty!");
    }
    if (
PlayerData[playerid][pDrivingTest])
    {
        
SetTimerEx("PutInsideVehicle"500false"dd"playeridvehicleid);
        
Dialog_Show(playeridLeaveTestDIALOG_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:xFloat:yFloat:zFloat:a;
    new 
carid Car_Nearest(playerid);
    new 
id Car_GetID(vehicleid);
    new 
Float:vHealth;
    new 
veh;
    
veh GetPlayerVehicleID(playerid);
    
GetVehicleHealth(vehvHealth);
    
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 !
Reply
#2

Can u show us your Car_GetID(vehicleid) and Car_Nearest(playerid) function?
Reply
#3

PHP Code:
stock Car_GetID(vehicleid)
{
    for (new 
0!= MAX_DYNAMIC_CARS++) 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 
0!= MAX_DYNAMIC_CARS++) if (CarData[i][carExists]) {
        
GetVehiclePos(CarData[i][carVehicle], fXfYfZ);
        if (
IsPlayerInRangeOfPoint(playerid3.0fXfYfZ)) {
            return 
i;
        }
    }
    return -
1;


here you have my friend
Reply
#4

Solved Guys, look at the top !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)