23.06.2016, 13:45
Quote:
If a line needs to be updated then generally the whole file needs to be rewritten from scratch. Unless you know exactly where you want to write as in that case you can use fseek() to move the cursor the right location. However this implies that the length of each line is the same and that's not the case here.
Also don't assume that any file is an INI. The INI syntax is very specific. |
Код:
public UpdateVehicle() { for(new IDVEH = 1; IDVEH < MAX_VEHICLES; IDVEH++) { new File: file2 = fopen("vehicles.cfg", io_readwrite); new coordsstring[258]; format(coordsstring, sizeof(coordsstring), "%d|%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d", CarSystem[IDVEH][cModel], CarSystem[IDVEH][cEssence], CarSystem[IDVEH][cX], CarSystem[IDVEH][cY], CarSystem[IDVEH][cZ], CarSystem[IDVEH][cAngle], CarSystem[IDVEH][cColor1], CarSystem[IDVEH][cColor2], CarSystem[IDVEH][cKM], CarSystem[IDVEH][cObjective], CarSystem[IDVEH][cDoorsLocked], CarSystem[IDVEH][cVehicleType], CarSystem[IDVEH][cPlaque], CarSystem[IDVEH][cVehicleMaterials], CarSystem[IDVEH][cVehicleCrack], CarSystem[IDVEH][cVehiclePot], CarSystem[IDVEH][cJantes], CarSystem[IDVEH][cMetre], CarSystem[IDVEH][cVehicleHealth], CarSystem[IDVEH][cVehicleAlarm], CarSystem[IDVEH][cVehicleOwned], CarSystem[IDVEH][cDescription], CarSystem[IDVEH][cOwner], CarSystem[IDVEH][cNitro], CarSystem[IDVEH][cLoad], CarSystem[IDVEH][veh_int], CarSystem[IDVEH][veh_world], CarSystem[IDVEH][cPaintJob], CarSystem[IDVEH][cHydro], CarSystem[IDVEH][cPimped], CarSystem[IDVEH][cPerma], CarSystem[IDVEH][cRank], CarSystem[IDVEH][cPrice], CarSystem[IDVEH][cSpoiler], CarSystem[IDVEH][cFbumper], CarSystem[IDVEH][cRbumper]); fwrite(file2, coordsstring); fclose(file2); } return 1; }