Vehicle loading problem
#6

I think I see what you're trying to do, to assign a vehicle an ID (MySQL ID on the database you must do this...I don't understand where you're creating the vehicles...

Try something like this:

pawn Код:
public OnVehicleLoad()
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    for(new i = 0; i != rows; i++)
    {
        new vehicleid = CreateVehicle(VehInfo[i][ModelID]), VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ], 90, 1, 1, 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.");
    }
}
You added a lot of unnecessary functions. Just use the created vehicle id! Hope this helps. I've not tested it, it's possibly not complete or I've missed something.
Reply


Messages In This Thread
Vehicle loading problem - by TwinkiDaBoss - 25.11.2015, 20:23
Re: Vehicle loading problem - by CmZxC - 25.11.2015, 20:39
Re: Vehicle loading problem - by TwinkiDaBoss - 25.11.2015, 20:47
Re: Vehicle loading problem - by CmZxC - 25.11.2015, 20:54
Re: Vehicle loading problem - by TwinkiDaBoss - 25.11.2015, 20:58
Re: Vehicle loading problem - by Dokins - 26.11.2015, 11:16
Re: Vehicle loading problem - by TwinkiDaBoss - 26.11.2015, 14:25
Re: Vehicle loading problem - by CmZxC - 26.11.2015, 14:47
Re: Vehicle loading problem - by TwinkiDaBoss - 26.11.2015, 14:50
Re: Vehicle loading problem - by CmZxC - 26.11.2015, 14:51

Forum Jump:


Users browsing this thread: 1 Guest(s)