Parts saving but not loading, so weird!
#1

pawn Код:
public LoadCar()
{
    new arrCoords[30][64];
    new strFromFile2[256];
    new File: file = fopen("dealership.cfg", io_read);
    if (file)
    {
        new idx = 0;
        while (idx < sizeof(CarInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            CarInfo[idx][vModel] = strval(arrCoords[0]);
            CarInfo[idx][vLocationx] = floatstr(arrCoords[1]);
            CarInfo[idx][vLocationy] = floatstr(arrCoords[2]);
            CarInfo[idx][vLocationz] = floatstr(arrCoords[3]);
            CarInfo[idx][vAngle] = floatstr(arrCoords[4]);
            CarInfo[idx][vColorOne] = strval(arrCoords[5]);
            CarInfo[idx][vColorTwo] = strval(arrCoords[6]);
            strmid(CarInfo[idx][vOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(CarInfo[idx][vDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            CarInfo[idx][vValue] = strval(arrCoords[9]);
            CarInfo[idx][vLicense] = strval(arrCoords[10]);
            CarInfo[idx][vOwned] = strval(arrCoords[11]);
            CarInfo[idx][vLock] = strval(arrCoords[12]);
            CarInfo[idx][vMod1] = strval(arrCoords[13]);
            CarInfo[idx][vMod2] = strval(arrCoords[14]);
            CarInfo[idx][vMod3] = strval(arrCoords[15]);
            CarInfo[idx][vMod4] = strval(arrCoords[16]);
            CarInfo[idx][vMod5] = strval(arrCoords[17]);
            CarInfo[idx][vMod6] = strval(arrCoords[18]);
            CarInfo[idx][vMod7] = strval(arrCoords[19]);
            CarInfo[idx][vMod8] = strval(arrCoords[20]);
            CarInfo[idx][vMod9] = strval(arrCoords[21]);
            CarInfo[idx][vMod10] = strval(arrCoords[22]);
            CarInfo[idx][vMod11] = strval(arrCoords[23]);
            CarInfo[idx][vMod12] = strval(arrCoords[24]);
            CarInfo[idx][vMod13] = strval(arrCoords[25]);
            CarInfo[idx][vMod14] = strval(arrCoords[26]);
            CarInfo[idx][vMod15] = strval(arrCoords[27]);
            CarInfo[idx][vMod16] = strval(arrCoords[28]);
            CarInfo[idx][vMod17] = strval(arrCoords[29]);
            CarInfo[idx][ownedvehicle] = CreateVehicle(CarInfo[idx][vModel],CarInfo[idx][vLocationx],CarInfo[idx][vLocationy],CarInfo[idx][vLocationz],CarInfo[idx][vAngle],CarInfo[idx][vColorOne],CarInfo[idx][vColorTwo],300000);
            printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][vOwner],CarInfo[idx][vLicense]);
            idx++;
        }
    }
    return 1;
}
//==============================================================================
public SaveCars()
{
    new idx;
    new File: file2;
    while (idx < sizeof(CarInfo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,\n",
        CarInfo[idx][vModel],
        CarInfo[idx][vLocationx],
        CarInfo[idx][vLocationy],
        CarInfo[idx][vLocationz],
        CarInfo[idx][vAngle],
        CarInfo[idx][vColorOne],
        CarInfo[idx][vColorTwo],
        CarInfo[idx][vOwner],
        CarInfo[idx][vDescription],
        CarInfo[idx][vValue],
        CarInfo[idx][vLicense],
        CarInfo[idx][vOwned],
        CarInfo[idx][vLock],
        CarInfo[idx][vMod1],
        CarInfo[idx][vMod2],
        CarInfo[idx][vMod3],
        CarInfo[idx][vMod4],
        CarInfo[idx][vMod5],
        CarInfo[idx][vMod6],
        CarInfo[idx][vMod7],
        CarInfo[idx][vMod8],
        CarInfo[idx][vMod9],
        CarInfo[idx][vMod10],
        CarInfo[idx][vMod11],
        CarInfo[idx][vMod12],
        CarInfo[idx][vMod13],
        CarInfo[idx][vMod14],
        CarInfo[idx][vMod15],
        CarInfo[idx][vMod16],
        CarInfo[idx][vMod17]);
        if(idx == 0)
        {
            file2 = fopen("dealership.cfg", io_write);
        }
        else
        {
            file2 = fopen("dealership.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
It happens when I modify a car, the component ID saves to the file but not to the car, and then it won't load it to the car from the file. But everything else loads and saves to the vehicle. Here's an example from the file:
Код:
560,-2704.822509,256.125457,3.885612,175.476440,4,4,Louis,,20000,,1,0,1138,1009,1169,1140,1029,0,0,0,1032,1026,0,1087,1086,0,0,1085,0,
Help ASAP would be appreciated so much!!
Reply
#2

Use "print()" to make some debugging messages in your script; it could be loosing data somehow during loading/saving.
Reply
#3

I have a print() at the end of LoadCar which works fine, so obviously it loads it all? :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)