Vehicles not loading correctly (Threaded MySQL)
#1

Okay, I can't turn my own vehicle's engine on or anything, there seems to be conflicting ID's but I can't understand why.

I'm loading the vehicles into a variable.


pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
    //mysql_query( "SELECT id, VehModel,VehOwner, VehColour1, VehColour2, VehPlate, VehSpawnX, VehSpawnY, VehSpawnZ, VehSpawnAngle, VehFuel, VehCash,VehWep1,VehWepA1,VehWep2,VehWepA2, VehArmour,VehFaction,VehFRank, VehOwned, VehFactioned, VehWeed, VehCoke, VehBizID, VehForSale,VehPrice FROM vehicles");
    //mysql_store_result();
    new rows, fields, vehicleid, x;
    cache_get_data(rows, fields); // if the rows are more than the size of the variable, reset the rows to match (to avoid run time error 4)
    for(new y; y != rows; ++y)
    {
        x = cache_get_row_int(y, vvid);
        printf("% VEHICLESQLID", x);
        VehModel[x] = cache_get_row_int(y, vVehModel);
        VehColour1[x] = cache_get_row_int(y, vVehColour1);
        VehColour2[x] = cache_get_row_int(y, vVehColour2);
        VehSpawnX[x] = cache_get_row_float(y, vVehSpawnX);
        VehSpawnY[x] = cache_get_row_float(y, vVehSpawnY);
        VehSpawnZ[x] = cache_get_row_float(y, vVehSpawnZ);
        VehSpawnAngle[x] = cache_get_row_float(y, vVehSpawnAngle);
        VehSiren[x] = cache_get_row_int(y, vVehSiren);
        vehicleid = CreateVehicle(VehModel[x], VehSpawnX[x], VehSpawnY[x],VehSpawnZ[x], VehSpawnAngle[x], VehColour1[x], VehColour2[x], -1, VehSiren[x]);
       
        cache_get_row(y,vVehPlate, VehPlate[x]);
        VehOwner[x] = cache_get_row_int(y, vVehOwner);
        printf("%d owner", VehOwner[x]);
        VehJob[x] = cache_get_row_int(y, vVehJob);
        VehFuel[x] = cache_get_row_int(y, vVehFuel);
        VehCash[x] = cache_get_row_int(y,vVehCash);
        VehWeed[x] = cache_get_row_int(y, vVehWeed);
        VehCoke[x] = cache_get_row_int(y, vVehCoke);
        VehLock[x] = cache_get_row_int(y, vVehLock);
        VehAlarm[x] = cache_get_row_int(y, vVehAlarm);
        VehicleFaction[x] = cache_get_row_int(y, vVehFaction);
        VehicleRank[x] = cache_get_row_int(y, vVehFRank);
        VehOwned[x] = cache_get_row_int(y, vVehOwned);
        VehFactioned[x] = cache_get_row_int(y, vVehFactioned);
        VehArmour[x] = cache_get_row_float(y, vVehArmour);
        VehBizID[x] = cache_get_row_int(y, vVehBizID);
        VehForSale[x] = cache_get_row_int(y, vVehForSale);
        VehPrice[x] = cache_get_row_int(y, vVehPrice);
        VehWepSlots[x] = cache_get_row_int(y, vVehWepSlots);
        VehFType[x] = cache_get_row_int(y, vVehFType);
        printf("%d Ftype", VehFType[x]);
        VehSpark[x] = cache_get_row_int(y, vVehSpark);
        VehWater[x] = cache_get_row_int(y, vVehWater);
        VehGear[x] = cache_get_row_int(y, vVehGear);
        VehElec[x] = cache_get_row_int(y, vVehElec);
        VehOil[x] = cache_get_row_int(y, vVehOil);
        VehExhaust[x] = cache_get_row_int(y, vVehExhaust);
        VehFLine[x] = cache_get_row_int(y, vVehFLine);
        VehRadi[x] = cache_get_row_int(y, vVehRadi);
        VehBattery[x] = cache_get_row_int(y, vVehBattery);
        VehFSize[x] = cache_get_row_int(y, vVehFSize);
        printf("%d Fsize", VehFSize[x]);
        VehTyres[x] = cache_get_row_int(y, vVehTyres);
        VehFUsed[x] = cache_get_row_int(y, vVehFUsed);
        VehVMarker[x] = cache_get_row_int(y, vVehVMarker);
        VehFMarker[x] = cache_get_row_int(y, vVehFMarker);
        VehNMarker[x] = cache_get_row_int(y, vVehNMarker);
        VehHealth[x] = cache_get_row_float(y, vVehHealth);
        VehPanels[x] = cache_get_row_int(y, vVehPanels);
        VehDoors[x] = cache_get_row_int(y, vVehDoors);
        VehLights[x] = cache_get_row_int(y, vVehLights);
        VehFSlots[x] = cache_get_row_int(y, vVehFSlots);

        LoadVehicleData(vehicleid, x);
    }
    return 1;
}
I then use the variable to assign to vehicle ID's but they turn out incorrect, even though displaying the correct VehicleSQLID.

Here's where I load them into the vehicle (server side).
pawn Код:
stock LoadVehicleData(vehicleid, x)
{
    VehicleSQLID[vehicleid] = x;
    printf("%d vehmysql", VehicleSQLID[vehicleid]);
    printf("%d vehicleid", vehicleid);
    VehModel[vehicleid] = VehModel[x];
    printf("Veh Model: %d VehModel %d VehSQLModel %d", GetVehicleModel(vehicleid), VehModel[vehicleid], VehModel[x]);
    printf("%s VehModel %s",VehicleNames[GetVehicleModel(vehicleid) - 400], VehicleNames[VehModel[vehicleid] - 400]);
    VehColour1[vehicleid] = VehColour1[x];
    printf("%d", VehColour1[vehicleid]);
    VehColour2[vehicleid] = VehColour2[x];
    VehSpawnX[vehicleid] = VehSpawnX[x];
    VehSpawnY[vehicleid] = VehSpawnY[x];
    VehSpawnZ[vehicleid] = VehSpawnZ[x];
    VehSpawnAngle[vehicleid] = VehSpawnAngle[x];
    VehSiren[vehicleid] = VehSiren[x];
    SetVehicleHealth(vehicleid, VehHealth[x]);
    VehOwner[vehicleid] = VehOwner[x];
    VehJob[vehicleid] =  VehJob[vehicleid];
    VehFuel[vehicleid] = VehFuel[vehicleid];
    VehCash[vehicleid] = VehCash[vehicleid];
    VehWeed[vehicleid] = VehWeed[x];
    VehCoke[vehicleid] = VehCoke[x];
    VehLock[vehicleid] = VehLock[x];
    VehAlarm[vehicleid] = VehAlarm[x];
    VehicleFaction[vehicleid] = VehicleFaction[x];
    VehicleRank[vehicleid] = VehicleRank[x];
    VehOwned[vehicleid] = VehOwned[x];
    VehFactioned[vehicleid] = VehFactioned[x];
    VehArmour[vehicleid] = VehArmour[x];
    VehBizID[vehicleid] = VehBizID[x];
    VehForSale[vehicleid] = VehForSale[x];
    VehPrice[vehicleid] = VehPrice[x];
    VehWepSlots[vehicleid] = VehWepSlots[x];
    VehFType[vehicleid] = VehFType[x];
    VehSpark[vehicleid] = VehSpark[x];
    VehWater[vehicleid] = VehWater[x];
    VehGear[vehicleid] = VehGear[x];
    VehElec[vehicleid] = VehElec[x];
    VehOil[vehicleid] = VehOil[x];
    VehExhaust[vehicleid] = VehExhaust[x];
    VehFLine[vehicleid] = VehFLine[x];
    VehRadi[vehicleid] = VehRadi[x];
    VehBattery[vehicleid] = VehBattery[x];
    VehFSize[vehicleid] = VehFSize[x];
    VehTyres[vehicleid] = VehTyres[x];
    VehFUsed[vehicleid] = VehFUsed[x];
    VehVMarker[vehicleid] = VehVMarker[x];
    VehFMarker[vehicleid] = VehFMarker[x];
    VehNMarker[vehicleid] = VehNMarker[x];
    VehFSlots[vehicleid] = VehFSlots[x];
    VehHealth[vehicleid] = VehHealth[x];
    VehPanels[vehicleid] = VehPanels[x];
    VehDoors[vehicleid] = VehDoors[x];
    VehLights[vehicleid] = VehLights[x];
    strcpy(VehPlate[vehicleid], VehPlate[x], 12);
    SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
    new string[12];
    if(VehicleFaction[vehicleid] > 0)
    {
        format(string, sizeof(string), "%s%d", ShortFName[VehicleFaction[vehicleid]], x);

        if(strcmp(string, VehPlate[vehicleid], false))
        {
            format(VehPlate[vehicleid], sizeof(VehPlate),"%s%d", ShortFName[VehicleFaction[vehicleid]], x);
            MySQL_SetString(x, "VehPlate", VehPlate[vehicleid], "vehicles");
            SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
        }
    }
    if(VehJob[vehicleid] == 1)
    {
        format(VehPlate[vehicleid], sizeof(VehPlate),"M3T3R%d", x);
        SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
    }
    if(VehJob[vehicleid] == 2)
    {
        format(VehPlate[vehicleid], sizeof(VehPlate), "TAXI%d", x);
        SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
    }


    if(VehicleFaction[vehicleid] == 0)
    {
        printf("PLATE %s - not faction", VehPlate[vehicleid]);
        SetVehicleNumberPlate(vehicleid, VehPlate[vehicleid]);
    }


    SetVehicleParamsEx(vehicleid, 0, 0, 0, VehLock[vehicleid], 0, 0, 0);
    SetVehicleParamsCarDoors(vehicleid, 0,0,0,0);
    SetVehicleParamsCarWindows(vehicleid, 1,1, 1, 1);
    if(VehOwner[vehicleid] > 0)
    {
        UpdateVehicleDamageStatus(vehicleid, VehPanels[vehicleid], VehDoors[vehicleid], VehLights[vehicleid], VehTyres[vehicleid]);
    }
    if(VehForSale[vehicleid] == 1)
    {
        new name = VehModel[vehicleid] - 400;
        format(string, sizeof(string), "%s, $%s, %s", VehicleNames[name], AddCommas(VehPrice[vehicleid]), VehPlate[vehicleid]);
        VehicleLabel[vehicleid] = CreateDynamic3DTextLabel(string, COLOUR_ORANGE, VehSpawnX[vehicleid],VehSpawnY[vehicleid], VehSpawnZ[vehicleid], 100.0, INVALID_PLAYER_ID, vehicleid, 0, 0, -1, -1, 20.0);
        Attach3DTextLabelToVehicle(VehicleLabel[vehicleid] ,vehicleid,0.0,0.0,0.0);
    }
}
All the printf's are returning correctly, I just don't understand.
Reply
#2

I hope you did comment these line on purpose for the sake of displaying the script?
pawn Код:
//mysql_query( "SELECT id, VehModel,VehOwner, VehColour1, VehColour2, VehPlate, VehSpawnX, VehSpawnY, VehSpawnZ, VehSpawnAngle, VehFuel, VehCash,VehWep1,VehWepA1,VehWep2,VehWepA2, VehArmour,VehFaction,VehFRank, VehOwned, VehFactioned, VehWeed, VehCoke, VehBizID, VehForSale,VehPrice FROM vehicles");
//mysql_store_result();
Also, instead of grabbing every column with
pawn Код:
SELECT id, VehModel,VehOwner, VehColour1, VehColour2
Why aren't you loading everything from the database with
pawn Код:
SELECT * FROM `vehicles`
Reply
#3

That's the old code, I am loading it with that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)