I am trying to load vehicles via MySQL, but the script only seems to be grabbing data for the first vehicle (i.e. 1st result)
As you can see here, is it is ignoring the data for the rest, only grabbing the first one.
PHP код:
forward OnDynamicVehicleLoad();
public OnDynamicVehicleLoad()
{
new rows = cache_num_rows(), sqlID, smallStr[32];
for (new i = 0; i < rows; i ++) if (i < MAX_DYNAMIC_VEHICLES)
{
printf("[Vehicle.pwn] Setting Vehicle %d/%d", i+1, rows);
cache_get_value_name_int(i, "VehicleID", sqlID);
VehicleData[i+1][vID] = sqlID;
cache_get_value_name_int(i, "ModelID", VehicleData[i+1][vModelID]);
cache_get_value_name_float(i, "LocationX", VehicleData[i+1][vLocationX]);
cache_get_value_name_float(i, "LocationY", VehicleData[i+1][vLocationY]);
cache_get_value_name_float(i, "LocationZ", VehicleData[i+1][vLocationZ]);
cache_get_value_name_float(i, "LocationR", VehicleData[i+1][vLocationR]);
cache_get_value_name_int(i, "Colour1", VehicleData[i+1][vColour1]);
cache_get_value_name_int(i, "Colour2", VehicleData[i+1][vColour2]);
cache_get_value_name_int(i, "OwnerID", VehicleData[i+1][vOwnerID]);
cache_get_value_name_int(i, "Faction", VehicleData[i+1][vFaction]);
for(new trunk; trunk < 5; trunk++)
{
format(smallStr, sizeof(smallStr), "TrunkWeapon%d", trunk);
cache_get_value_name_int(i, smallStr, VehicleData[i+1][vTrunkWeapon][trunk]);
format(smallStr, sizeof(smallStr), "TrunkAmmo%d", trunk);
cache_get_value_name_int(i, smallStr, VehicleData[i+1][vTrunkAmmo][trunk]);
}
cache_get_value_name_int(i, "Alarm", VehicleData[i+1][vAlarm]);
cache_get_value_name_int(i, "VehicleLock", VehicleData[i][vLock]);
cache_get_value_name_int(i, "Immob", VehicleData[i+1][vImmob]);
cache_get_value_name_int(i, "Impounded", VehicleData[i+1][vImpounded]);
cache_get_value_name_int(i, "ImpoundPrice", VehicleData[i+1][vImpoundPrice]);
cache_get_value_name_int(i, "Insurance", VehicleData[i+1][vInsurance]);
cache_unset_active();
printf("[Vehicle.pwn] Vehicle %d (SQLID: %d) ModelID = %d", i+1, VehicleData[i+1][vID], VehicleData[i+1][vModelID]);
if(VehicleData[i+1][vModelID] > 0)
{
VehicleData[i+1][vScriptID] = CreateVehicle(VehicleData[i+1][vModelID], VehicleData[i+1][vLocationX], VehicleData[i+1][vLocationY], VehicleData[i+1][vLocationZ], VehicleData[i+1][vLocationR], VehicleData[i+1][vColour1], VehicleData[i+1][vColour2], -1, 0);
printf("[Vehicle.pwn] VehicleID %d with ModelID %d spawned", i+1, VehicleData[i+1][vModelID]);
}
}
return 1;
}