LoadFile - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: LoadFile (
/showthread.php?tid=96537)
LoadFile -
Justsmile - 08.09.2009
I have a problem. I want to save my car coords into a .cfg file, but there is still 0.000000; so i crash, when i join the server.
public LoadRentCarsf()
http://pastebin.com/m1050b87f
here, OnPropUpdate:
http://pastebin.com/m2527e6e7
Pls help me,
maybe .cfg is wrong created, I copied the buzz.cfg and and delete content, rename tc.
Re: LoadFile -
Nero_3D - 09.09.2009
do you got a part where you save data to RentCarSF ?
the loading and saving looks ok, the only mistake is saw was
pawn Код:
printf("CarID:%d Float:X:%d Float:Y: %d Float:Z: %d Float:Angel:%d.\n",
idx, //should be "CarID:%d Float:X:%f Float:Y: %f Float:Z: %f Float:Angel:%f .\n"
RentCarSF[idx][rcarPosX],
RentCarSF[idx][rcarPosY],
RentCarSF[idx][rcarPosZ],
RentCarSF[idx][rcarAngel]);
in the loading part
Re: LoadFile -
Justsmile - 09.09.2009
Yes, onPlayereXIT cAR^^
That is not the problem i think. He don't load what is written in.cfg
he only print 0.000000
Re: LoadFile - Zeex - 09.09.2009
You forgot to put "fread(file, strFromFile2)" in your LoadRentCarSF()
Re: LoadFile -
Justsmile - 09.09.2009
What? pls exactly explain.
Maybe an example
Re: LoadFile - Zeex - 09.09.2009
fread reads a line from file, I didn't see you do it. That's why your coords are always 0.0.
pawn Код:
public LoadRentCarSF()
{
if(TOGGLE_DEBUG_MODE)
{
print(" //DEBUG: CALL LoadRentCarSF()");
}
new arrCoords[5][64];
new strFromFile2[256];
new File: file = fopen("rentcarsf.cfg", io_read);
if (file)
{
new idx;
new size = sizeof(RentCarSF);
while (fread(file, strFromFile) && idx < size)
{
split(strFromFile2, arrCoords, '|');
RentCarSF[idx][rcarModel] = strval(arrCoords[0]);
RentCarSF[idx][rcarPosX] = floatstr(arrCoords[1]);
RentCarSF[idx][rcarPosY] = floatstr(arrCoords[2]);
RentCarSF[idx][rcarPosZ] = floatstr(arrCoords[3]);
RentCarSF[idx][rcarAngel] = floatstr(arrCoords[4]);
printf("CarID:%d Float:X:%f Float:Y: %f Float:Z: %f Float:Angle:%f.\n",
idx,
RentCarSF[idx][rcarPosX],
RentCarSF[idx][rcarPosY],
RentCarSF[idx][rcarPosZ],
RentCarSF[idx][rcarAngel]);
idx++;
}
fclose(file);
}
return 1;
}
Re: LoadFile -
Justsmile - 09.09.2009
I get this Error
undefined symbol "strFromFile"
This Line:
while (fread(file, strFromFile) && idx < size)
Re: LoadFile -
Nero_3D - 09.09.2009
pawn Код:
while (fread(file, strFromFile2) && idx < size)
Re: LoadFile -
Justsmile - 09.09.2009
Ok, thanks. I will test it. PLs help me with the other email system. That would be great.