08.06.2012, 01:40
Your logic for the TuneCar parameter is plain wrong. But your enumeration is probably far too complex to spot it on the first sight. You see that as soon as you pass the ID value from the enum to TuneCar, the function will subtract 1 from the ID value and then access the enum WITH THE SAME INDEX.
Also, what's very bad, is that you use a query per vehicle. What's wrong with doing
And you were wondering about how to convert it, so I already started off by passing true as the value for caching, so lets see how it would work with cache:
To simplify your overall working process, why do you store the vehicle ID in the array with some other index, rather keep it as the index itself?
(Overall, I'm just too tired to understand your code)
pawn Code:
public OnVehicleSpawn(vehicleid)
{
TuneCar(vehicleid);
}
stock TuneCar(vehicleid)
{
new index = vehicleid - 1;
vehicleid = VehicleInfo[index][ID];
if(VehicleInfo[index][PaintJob] != -1) ChangeVehiclePaintjob(vehicleid, VehicleInfo[index][PaintJob]);
}
pawn Code:
mysql_function_query(1, "SELECT * FROM vehicledata WHERE Type != 8", true, "OnVehiclesLoad", "");
pawn Code:
forward OnVehiclesLoad();
public OnVehiclesLoad()
{
new rows, fields;
cache_get_data(rows, fields);
for(i = 0; i != rows; i++)
{
cache_get_row(i, 0, /* FIRST FIELD */);
}
return 1;
}
(Overall, I'm just too tired to understand your code)