09.12.2010, 22:10
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):
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:
When someone buy this car, script will create new line:
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.
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;
}
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
Code:
411,551.633239,-1263.060302,17.042186,215.000000,20,1,Firstname_Lastname,Infernus,1000000,1
I want to replace the existing line with that new line.
How to do that?
Sorry for my bad English.