Array index out of bounds when trying to read from dealership vehicles
#1

As the title says, I'm trying to make a dynamic dealership system in my server, but for some reason it doesn't work and Crash Detect gives me the "out of bounds" error.

This function is called whenever the player enters one of the dealership markers.
PHP код:
ShowDealerShipVehicles(playeriddealershipid
{
    new 
dealershiptitle[128], vehiclestring[128], holder[512];
    
    for(new 
isizeof(DealerShipVehicle); i++)
    {
        
format(vehiclestringsizeof(vehiclestring), "{FFFFFF}%s {FFFFFF}(%d)\n"vehiclestringVehicleName(DealerShipVehicle[i][Model]), DealerShipVehicle[i][Price]);
        
strcat(holdervehiclestringsizeof(holder));
        
//if(DealerShipVehicle[i][DealerShipID] == dealershipid) {
        //}
    
}
    
format(dealershiptitlesizeof(dealershiptitle), "Vehicle Menu for %s!"DealerShipData[dealershipid][dsName]);
    
ShowPlayerDialog(playeridDIALOG_DEALERSHIP_VEHICLESDIALOG_STYLE_LISTdealershiptitleholder"Buy""Cancel");
    return 
1;

To be sure, here's the part of my OnPlayerEnterDynamicCP:
PHP код:
for(new 0sizeof(DealerShipData); i++)
    {
        if(
IsPlayerInRangeOfPoint(playerid1.5DealerShipData[i][dsX], DealerShipData[i][dsY], DealerShipData[i][dsZ]))
        {
            
watchingDealerShip[playerid] = i;
            
ShowDealerShipVehicles(playeridwatchingDealerShip[playerid]+1);
            break;
        }
    } 
The dialog doesn't even show up either.

EDIT: Here's the error from the server:
Код:
[21:26:41] [debug] Run time error 4: "Array index out of bounds"
[21:26:41] [debug]  Accessing element at negative index -400
[21:26:41] [debug] AMX backtrace:
[21:26:41] [debug] #0 000471b8 in VehicleName (modelid=0) at crp.pwn:3048
[21:26:41] [debug] #1 000482b8 in ShowDealerShipVehicles (playerid=0, dealershipid=1) at crp.pwn:3375
[21:26:41] [debug] #2 00024224 in public OnPlayerEnterDynamicCP (playerid=0, checkpointid=21) at crp.pwn:1139
Reply


Messages In This Thread
Array index out of bounds when trying to read from dealership vehicles - by Jimmy0wns - 09.06.2015, 19:31
Re: Array index out of bounds when trying to read from dealership vehicles - by Konstantinos - 09.06.2015, 19:39
Re: Array index out of bounds when trying to read from dealership vehicles - by Jimmy0wns - 10.06.2015, 13:44

Forum Jump:


Users browsing this thread: 2 Guest(s)