Save error
#4

Why are you actually opening the file every iteration of the loop, saving one string and closing it again?
Opening and closing files is time-consuming and could lead to bugs.
Just open the file once, add your data to it and close it when you're finished.
pawn Код:
stock SaveDoors()
{
    new idx = 0, File:file;
    new string[256];

    // Open the file once for writing
    file = fopen("doors.cfg", io_write);

    while(idx < MAX_DOORS)
    {
        format(string, sizeof(string), "%d|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%f|%s|%f|%d|\r\n",
        DoorInfo[idx][dType],
        DoorInfo[idx][dOX],
        DoorInfo[idx][dOY],
        DoorInfo[idx][dOZ],
        DoorInfo[idx][dIX],
        DoorInfo[idx][dIY],
        DoorInfo[idx][dIZ],
        DoorInfo[idx][dOInt], //doesn't save
        DoorInfo[idx][dOVW], // doesn't save
        DoorInfo[idx][dIInt], // doesn't save
        DoorInfo[idx][dIVW], // doesn't save
        DoorInfo[idx][dCInt], //doesn't save
        DoorInfo[idx][dCExt], //doesn't save
        DoorInfo[idx][dIA],  //doesn't save
        DoorInfo[idx][dText], //doesn't save
        DoorInfo[idx][dOA], //doesn't save
        DoorInfo[idx][fTeam]); //doesn't save
        fwrite(file, string);
        idx++;
    }

    // Close the file after saving everything
    fclose(file);
}
Also, try to print your data to see if the saving is messing up, or you actually have no data in those variables.
Reply


Messages In This Thread
Save error - by MasonSFW - 24.10.2014, 07:55
Re: Save error - by Stanford - 24.10.2014, 08:07
Re: Save error - by MasonSFW - 24.10.2014, 08:13
Re: Save error - by PowerPC603 - 24.10.2014, 08:53
Re: Save error - by MasonSFW - 24.10.2014, 09:40
Re: Save error - by MasonSFW - 24.10.2014, 09:54

Forum Jump:


Users browsing this thread: 1 Guest(s)