public OnVehicleLoad()
{
new rows, fields;
cache_get_data(rows, fields, mysql);
for(new i = 0; i < rows; i++)
{
new vehicleid = CreateVehicle(cache_get_field_content_int(i,"ModelID"), cache_get_field_content_float(i,"PosX"),cache_get_field_content_float(i,"PosY"),cache_get_field_content_float(i,"PosZ"),cache_get_field_content_float(i,"PosA"),cache_get_field_content_int(i,"Color1"),cache_get_field_content_int(i,"Color2"),0,0);
VehInfo[vehicleid][VehMasterID] = cache_get_field_content_int(i,"MasterID");
VehInfo[vehicleid][VID] = cache_get_field_content_int(i,"ID");
VehInfo[vehicleid][ModelID] = cache_get_field_content_int(i,"ModelID");
VehInfo[vehicleid][Color1] = cache_get_field_content_int(i,"Color1");
VehInfo[vehicleid][Color2] = cache_get_field_content_int(i,"Color2");
VehInfo[vehicleid][VehPosX] = cache_get_field_content_float(i,"PosX");
VehInfo[vehicleid][VehPosY] = cache_get_field_content_float(i,"PosY");
VehInfo[vehicleid][VehPosZ] = cache_get_field_content_float(i,"PosZ");
VehInfo[vehicleid][VehPosA] = cache_get_field_content_float(i,"PosA");
VehInfo[vehicleid][VRespawnTime] = cache_get_field_content_int(i,"RespawnTime");
VehInfo[vehicleid][VPrice] = cache_get_field_content_int(i,"Price");
VehInfo[vehicleid][DamageStatus] = cache_get_field_content_float(i,"Damage");
VehInfo[vehicleid][FuelStatus] = cache_get_field_content_int(i,"FuelStatus");
VehInfo[vehicleid][EngineStatus] = cache_get_field_content_int(i,"EngineStatus");
VehInfo[vehicleid][Kilometrage] = cache_get_field_content_float(i,"Kilometrage");
VehInfo[vehicleid][vSiren] = cache_get_field_content_int(i,"Siren");
VehInfo[vehicleid][vOwned] = cache_get_field_content_int(i,"Owned");
VehInfo[vehicleid][VehWorld] = cache_get_field_content_int(i,"VirtualWorld");
VehInfo[vehicleid][VehInterior] = cache_get_field_content_int(i,"Interior");
SetVehicleVirtualWorld(vehicleid,VehInfo[vehicleid][VehWorld]);
LinkVehicleToInterior(vehicleid,VehInfo[vehicleid][VehInterior]);
SetVehiclePos(vehicleid,VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ]);
SetVehicleZAngle(vehicleid, VehInfo[vehicleid][VehPosA]);
VehiclesLoaded++;
}
printf("Total %i vehicles spawned",VehiclesLoaded);
if(VehiclesLoaded == 0)
{
printf("No vehicles loaded.");
}
}
SaveAllCars() { //saving all vehicles in SQL
new VehiclesSaved = 0;
for(new x = 1; x <= MAX_VEHICLES; x++) {
if(IsValidVehicle(x)) {
new Float:tmpStatus,query[128];
GetVehicleHealth(x,tmpStatus);
mysql_format(mysql, query, sizeof(query), "UPDATE `vehicles` SET `Color1`=%i,`Color2`=%i,`Damage`=%f,`FuelStatus`=%i,`Kilometrage`=%f WHERE `ID`=%d",\
VehInfo[x][Color1],VehInfo[x][Color2],tmpStatus,VehInfo[x][FuelStatus],VehInfo[x][Kilometrage],VehInfo[x][VID]);
mysql_tquery(mysql, query);
VehiclesSaved++;
}
}
printf("Total of %i vehicles saved",VehiclesSaved);
return true;
}
mysql_tquery(mysql, "SELECT * FROM `vehicles`", "OnVehicleLoad", "");
printf("Total %i vehicles spawned",VehiclesLoaded);
if(VehiclesLoaded == 0)
{
printf("No vehicles loaded.");
}
check when does MAX_VEHICLES stop
maybe MAX_VEHICLES is at like 50 that's why it only saves that much |
if(VehiclesLoaded == 0) { print("No vehicles loaded."); } else { printf("Total %i vehicles spawned",VehiclesLoaded); }
[03:53:52] MAX_VEHICLES = 2000
seems very strange, are you sure there are more than 9 vehicles in the vehicles table? if you are, then try putting a print inside your loop to pinpoint exactly when it stops and post back the results
|
[04:07:30] Number of vehicle models: 0
[04:07:30] Created vehicle model: 411. Server ID: 1. SQL ID: 39
[04:07:31] Created vehicle model: 400. Server ID: 2. SQL ID: 40
[04:07:31] Created vehicle model: 402. Server ID: 3. SQL ID: 41
[04:07:31] Created vehicle model: 411. Server ID: 4. SQL ID: 42
[04:07:31] Created vehicle model: 411. Server ID: 5. SQL ID: 43
[04:07:31] Created vehicle model: 411. Server ID: 6. SQL ID: 44
[04:07:31] Created vehicle model: 411. Server ID: 7. SQL ID: 45
[04:07:31] Created vehicle model: 451. Server ID: 8. SQL ID: 46
[04:07:31] Created vehicle model: 444. Server ID: 9. SQL ID: 47
printf("Created vehicle model: %i. Server ID: %i. SQL ID: %i",VehInfo[vehicleid][ModelID],vehicleid,VehInfo[vehicleid][VID]);
for(new i = 0; i < rows; i++)
{
VehInfo[vehicleid][VehMasterID] = cache_get_field_content_int(i,"MasterID");
VehInfo[vehicleid][VID] = cache_get_field_content_int(i,"ID");
VehInfo[vehicleid][ModelID] = cache_get_field_content_int(i,"ModelID");
VehInfo[vehicleid][Color1] = cache_get_field_content_int(i,"Color1");
VehInfo[vehicleid][Color2] = cache_get_field_content_int(i,"Color2");
VehInfo[vehicleid][VehPosX] = cache_get_field_content_float(i,"PosX");
VehInfo[vehicleid][VehPosY] = cache_get_field_content_float(i,"PosY");
VehInfo[vehicleid][VehPosZ] = cache_get_field_content_float(i,"PosZ");
VehInfo[vehicleid][VehPosA] = cache_get_field_content_float(i,"PosA");
VehInfo[vehicleid][VRespawnTime] = cache_get_field_content_int(i,"RespawnTime");
VehInfo[vehicleid][VPrice] = cache_get_field_content_int(i,"Price");
VehInfo[vehicleid][DamageStatus] = cache_get_field_content_float(i,"Damage");
VehInfo[vehicleid][FuelStatus] = cache_get_field_content_int(i,"FuelStatus");
VehInfo[vehicleid][EngineStatus] = cache_get_field_content_int(i,"EngineStatus");
VehInfo[vehicleid][Kilometrage] = cache_get_field_content_float(i,"Kilometrage");
VehInfo[vehicleid][vSiren] = cache_get_field_content_int(i,"Siren");
VehInfo[vehicleid][vOwned] = cache_get_field_content_int(i,"Owned");
VehInfo[vehicleid][VehWorld] = cache_get_field_content_int(i,"VirtualWorld");
VehInfo[vehicleid][VehInterior] = cache_get_field_content_int(i,"Interior");
SetVehicleVirtualWorld(vehicleid,VehInfo[vehicleid][VehWorld]);
LinkVehicleToInterior(vehicleid,VehInfo[vehicleid][VehInterior]);
SetVehiclePos(vehicleid,VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ]);
SetVehicleZAngle(vehicleid, VehInfo[vehicleid][VehPosA]);
VehiclesLoaded++;
new vehicleid = CreateVehicle(VehInfo[vehicleid][ModelID], VehInfo[vehicleid][VehPosX], VehInfo[vehicleid][VehPosY], VehInfo[vehicleid][VehPosZ], VehInfo[vehicleid][VehPosA], VehInfo[vehicleid][Color1], VehInfo[vehicleid][Color2], 0 0);
printf("CreateVehicle(%d, %.2f, %.2f, %.2f, %.2f, %d, %d, 0 ,0)", VehInfo[vehicleid][ModelID], VehInfo[vehicleid][VehPosX], VehInfo[vehicleid][VehPosY], VehInfo[vehicleid][VehPosZ], VehInfo[vehicleid][VehPosA], VehInfo[vehicleid][Color1], VehInfo[vehicleid][Color2]);
printf("row %d loaded succesfully.", i);
}
[04:16:02] CreateVehicle(411, 2280.13, -81.65, 26.52, 223.67, 0, 0, 0 ,0)
[04:16:02] row 0 loaded succesfully.
[04:16:02] CreateVehicle(400, 509.98, -1294.73, 16.96, 305.01, 0, 0, 0 ,0)
[04:16:02] row 1 loaded succesfully.
[04:16:02] CreateVehicle(402, 509.98, -1294.73, 16.96, 305.01, 0, 0, 0 ,0)
[04:16:02] row 2 loaded succesfully.
[04:16:02] CreateVehicle(411, 296.37, -1171.23, 80.63, 32.62, 0, 0, 0 ,0)
[04:16:02] row 3 loaded succesfully.
[04:16:02] CreateVehicle(411, -399.70, 1228.51, 6.32, 170.76, 0, 0, 0 ,0)
[04:16:02] row 4 loaded succesfully.
[04:16:02] CreateVehicle(411, 700.22, -833.43, 42.64, 107.18, 0, 0, 0 ,0)
[04:16:02] row 5 loaded succesfully.
[04:16:02] CreateVehicle(411, 1609.81, 311.53, 20.98, 263.44, 0, 0, 0 ,0)
[04:16:02] row 6 loaded succesfully.
[04:16:02] CreateVehicle(451, 1681.56, -334.12, 45.04, 192.19, 0, 0, 0 ,0)
[04:16:02] row 7 loaded succesfully.
[04:16:02] CreateVehicle(444, 1677.10, -319.05, 45.09, 188.23, 1, 1, 0 ,0)
[04:16:02] row 8 loaded succesfully.
new rows, fields;
cache_get_data(rows, fields, mysql);
printf("ROW COUNT: Method 1: %i, Method 2: %i", rows, cache_get_row_count());