25.11.2015, 20:39
Well, you have a loop in a loop, but I won't bother too much with that.
Anyway, try this.
Anyway, try this.
PHP код:
public OnVehicleLoad()
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
for(new i = 0; i < rows && i < MAX_VEHICLES; i++){
for(new x = 0; x < MAX_LOADED_CARS;x++) {
if(VehInfo[i][vCreated][x]) continue;
VehInfo[i][VehMasterID] = cache_get_field_content_int(i,"MasterID");
VehInfo[i][VID] = cache_get_field_content_int(i,"ID");
VehInfo[i][ModelID] = cache_get_field_content_int(i,"ModelID");
VehInfo[i][Color1] = cache_get_field_content_int(i,"Color1");
VehInfo[i][Color2] = cache_get_field_content_int(i,"Color2");
VehInfo[i][VehPosX] = cache_get_field_content_float(i,"PosX");
VehInfo[i][VehPosY] = cache_get_field_content_float(i,"PosY");
VehInfo[i][VehPosZ] = cache_get_field_content_float(i,"PosZ");
VehInfo[i][VehPosA] = cache_get_field_content_float(i,"PosA");
VehInfo[i][VRespawnTime] = cache_get_field_content_int(i,"RespawnTime");
VehInfo[i][VPrice] = cache_get_field_content_int(i,"Price");
VehInfo[i][DamageStatus] = cache_get_field_content_float(i,"Damage");
VehInfo[i][FuelStatus] = cache_get_field_content_int(i,"FuelStatus");
VehInfo[i][EngineStatus] = cache_get_field_content_int(i,"EngineStatus");
VehInfo[i][Kilometrage] = cache_get_field_content_float(i,"Kilometrage");
VehInfo[i][vSiren] = cache_get_field_content_int(i,"Siren");
VehInfo[i][vOwned] = cache_get_field_content_int(i,"Owned");
VehInfo[i][VehWorld] = cache_get_field_content_int(i,"VirtualWorld");
VehInfo[i][VehInterior] = cache_get_field_content_int(i,"Interior");
VehInfo[i][vCreated][x] = CreateServerVehicle(VehInfo[i][ModelID],VehInfo[i][VehPosX],VehInfo[i][VehPosY],VehInfo[i][VehPosZ],VehInfo[i][VehPosA],VehInfo[i][Color1],VehInfo[i][Color2],VehInfo[i][VRespawnTime],VehInfo[i][vSiren]);
SetVehicleVirtualWorld(VehInfo[i][vCreated][x],VehInfo[i][VehWorld]);
LinkVehicleToInterior(VehInfo[i][vCreated][x],VehInfo[i][VehInterior]);
SetVehiclePos(VehInfo[i][vCreated][x],VehInfo[i][VehPosX],VehInfo[i][VehPosY],VehInfo[i][VehPosZ]);
SetVehicleZAngle(VehInfo[i][vCreated][x],VehInfo[i][VehPosA]);
VehiclesLoaded++;
}
}
printf("Total %i vehicles spawned",VehiclesLoaded);
}
else print("No vehicles to be loaded..");
return true;
}