Quote:
Originally Posted by Zh3r0
I know that it uses a delimiter, that's not a problem at all, as SQLite uses columns, which is better.
But I get stuck at understanding the following code.
pawn Код:
new coordsstring[256]; format(coordsstring, sizeof(coordsstring), "%i,%i,%i,%i,%i,%i,%i,%i,%i,%f\n", vehTrunk[idx][1], vehTrunkAmmo[idx][1], vehTrunk[idx][2], vehTrunkAmmo[idx][2], vehTrunk[idx][3], vehTrunkAmmo[idx][3], vehTrunk[idx][4], vehTrunkAmmo[idx][4], vehTrunkCounter[idx], vehTrunkArmour[idx]); if(idx == 1) { file2 = fopen("LARP/Trunks/trunk.cfg", io_write); } else { file2 = fopen("LARP/Trunks/trunk.cfg", io_append); } fwrite(file2, coordsstring); idx++; fclose(file2);
Ok, the part that I don't understand is
pawn Код:
if(idx == 1) { file2 = fopen("LARP/Trunks/trunk.cfg", io_write); } else { file2 = fopen("LARP/Trunks/trunk.cfg", io_append); }
Does it re-write them or "update" ?
Also this code is part of a while function, and the idx integer value is 184, why?
|
we have IDX 0 and we will add 1 to it for each formatted and write'd line so while idx is lover than a max_something server will save lines to file (until it gets to max_something)
io_write writes a FIRST LINE AND OVERRIDE everything alse
io_append writes a line at the end of the file
you see if idx is 1 (first line) it will override file if idx is not 1 it must be 2,3 or whatever but not lover so it will just add line at the end of the file
[EDIT]Since you converting it to sqlLite you will just need to update that info