[HELP] Saving data into a file
#1

Hi

File functions, savings, readings, etc are my nightmear I'm total noob for file functions

Ok, I have this func for saving vehicles (ownership):
pawn Code:
public SacuvajVozila()
{
    new idx;
    new File: file2;
    while (idx < sizeof(Vozilo))
    {
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d\n",
        Vozilo[idx][hModel],
        Vozilo[idx][hPozX],
        Vozilo[idx][hPozY],
        Vozilo[idx][hPozZ],
        Vozilo[idx][hPozA],
        Vozilo[idx][hBoja1],
        Vozilo[idx][hBoja2],
        Vozilo[idx][hVlasnik],
        Vozilo[idx][hOpis],
        Vozilo[idx][hCena],
        Vozilo[idx][hImaVlasnika]);
        /*if(idx == 0)
        {
            file2 = fopen("VozilaOwnership.cfg", io_write);
        }
        else
        {
            file2 = fopen("VozilaOwnership.cfg", io_append);
        }*/

        file2 = fopen("VozilaOwnership.cfg", io_write);
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
This function is called in GameModeExitFunc (godfather mode)
My problem is that when i restart my server (gmx), new vehicles data is just add into a file.
For example, this is one line from VozilaOwnership.cfg:
Code:
411,551.633239,-1263.060302,17.042186,215.000000,20,1,Autosalon,Infernus,1000000,0
When someone buy this car, script will create new line:
Code:
411,551.633239,-1263.060302,17.042186,215.000000,20,1,Firstname_Lastname,Infernus,1000000,1
The problem is that what new line just add on end of file.
I want to replace the existing line with that new line.

How to do that?


Sorry for my bad English.
Reply


Messages In This Thread
[HELP] Saving data into a file - by Pooh7 - 09.12.2010, 22:10
Re: [HELP] Saving data into a file - by kiss - 10.12.2010, 05:11
Re: [HELP] Saving data into a file - by Pooh7 - 10.12.2010, 06:41
Respuesta: [HELP] Saving data into a file - by kirk - 10.12.2010, 13:24
Re: [HELP] Saving data into a file - by smeti - 10.12.2010, 16:27

Forum Jump:


Users browsing this thread: 1 Guest(s)