24.12.2013, 17:16
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:
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.
Then:
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 ]
pawn Код:
new Float: SpeedOfVehicles[212] = {
160.0, // modelid: 400
// ... {the rest of the speed values for each model},
0.0 // modelid: 611
};
pawn Код:
new
modelid = GetVehicleModel(GetPlayerVehicleID(playerid));
if (modelid) // valid modelid
{
// ...
new bar = floatround(GetVehicleSpeed(GetPlayerVehicleID(playerid)) / SpeedOfVehicles[modelid - 400] * 30, floatround_round);
// ...
}