Save error
#1

Why save some thing doesn't get save ?

pawn Код:
stock SaveDoors()
{
    new idx = 0, File:file;
    new string[256];
    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
        if(idx == 0)
        {
            file = fopen("doors.cfg", io_write);
        }
        else
        {
            file = fopen("doors.cfg", io_append);
        }
        fwrite(file, string);
        fclose(file);
        idx++;
    }
}
This code was saved
Код:
1314|77.500000|2397.139892|16.484375|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||1.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
0|0.000000|0.000000|0.000000|0.000000|0.000000|0.000000|0|0|0|0|0|0|0.000000||0.000000|0|
Reply
#2

It actually saves?
Reply
#3

yeah, incorrect saved code, It save only pickup id and position
Reply
#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
#5

Same it didn't save Text Label
Reply
#6

NVM I FIXED
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)