LoadFile
#1

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.
Reply
#2

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
Reply
#3

Yes, onPlayereXIT cAR^^

That is not the problem i think. He don't load what is written in.cfg
he only print 0.000000
Reply
#4

You forgot to put "fread(file, strFromFile2)" in your LoadRentCarSF()
Reply
#5

What? pls exactly explain.
Maybe an example
Reply
#6

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;
}
Reply
#7

I get this Error
undefined symbol "strFromFile"

This Line:

while (fread(file, strFromFile) && idx < size)
Reply
#8

pawn Код:
while (fread(file, strFromFile2) && idx < size)
Reply
#9

Ok, thanks. I will test it. PLs help me with the other email system. That would be great.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)