Improving and bugfixing a mysql loading process (Vehicles)
#2

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.

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]);
}
Also, what's very bad, is that you use a query per vehicle. What's wrong with doing
pawn Code:
mysql_function_query(1, "SELECT * FROM vehicledata WHERE Type != 8", true, "OnVehiclesLoad", "");
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:
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;
}
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)
Reply


Messages In This Thread
Improving and bugfixing a mysql loading process (Vehicles) - by Patrik356b - 08.06.2012, 01:13
Re: Improving and bugfixing a mysql loading process (Vehicles) - by AndreT - 08.06.2012, 01:40
Re: Improving and bugfixing a mysql loading process (Vehicles) - by Patrik356b - 08.06.2012, 13:03

Forum Jump:


Users browsing this thread: 1 Guest(s)