Run time error 4: "Array index out of bounds" at crashdedect.
#2

That's an odd one. It's like the size of the array is 1 and the valid index is 0 but it accessed the element at index 11.

You do have a 2D array that gets only float and you have only float points (the speed). Then your code is:
pawn Код:
SpeedOfVehicles[ vehar ][ model - 400 ]
vehar is the vehicleid? Well, it's pretty pointless. All you need is the modelid so you can subtract from 400 and get the speed on the single array.

pawn Код:
new Float: SpeedOfVehicles[212] = {
    160.0, // modelid: 400
    // ... {the rest of the speed values for each model},
    0.0 // modelid: 611
};
Then:
pawn Код:
new
    modelid = GetVehicleModel(GetPlayerVehicleID(playerid));

if (modelid) // valid modelid
{
    // ...
    new bar = floatround(GetVehicleSpeed(GetPlayerVehicleID(playerid)) / SpeedOfVehicles[modelid - 400] * 30, floatround_round);
    // ...
}
Reply


Messages In This Thread
Run time error 4: "Array index out of bounds" at crashdedect. - by dovyansas - 24.12.2013, 16:34
Re: Run time error 4: "Array index out of bounds" at crashdedect. - by Konstantinos - 24.12.2013, 17:16
Re: Run time error 4: "Array index out of bounds" at crashdedect. - by dovyansas - 24.12.2013, 18:09

Forum Jump:


Users browsing this thread: 1 Guest(s)