Save error - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Save error (
/showthread.php?tid=543052)
Save error -
MasonSFW - 24.10.2014
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|
Re: Save error -
Stanford - 24.10.2014
It actually saves?
Re: Save error -
MasonSFW - 24.10.2014
yeah, incorrect saved code, It save only pickup id and position
Re: Save error -
PowerPC603 - 24.10.2014
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.
Re: Save error -
MasonSFW - 24.10.2014
Same it didn't save Text Label
Re: Save error -
MasonSFW - 24.10.2014
NVM I FIXED