forward SaveCars();
public SaveCars()
{
new idx;
new File: file2 = fopen("cars.cfg", io_append);
while (idx < sizeof(CarInfo))
{
new coordsstring[800]; // 0 1 2 4 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i,%i,%i,%i,%d,%d\n",
CarInfo[idx][cModel], // 0
CarInfo[idx][cLocationx], // 1
CarInfo[idx][cLocationy], // 2
CarInfo[idx][cLocationz], // 3
CarInfo[idx][cAngle], //4
CarInfo[idx][cColorOne], //5
CarInfo[idx][cColorTwo], //6
CarInfo[idx][cOwner], //7
CarInfo[idx][cDescription], //8
CarInfo[idx][cValue], //9
CarInfo[idx][cPlate], //10
CarInfo[idx][cOwnedCar], //11
CarInfo[idx][cLock], //12
CarInfo[idx][cMod][0], //13
CarInfo[idx][cMod][1], //14
CarInfo[idx][cMod][2], //15
CarInfo[idx][cMod][3], //16
CarInfo[idx][cMod][4], //17
CarInfo[idx][cMod][5], //18
CarInfo[idx][cMod][6], //19
CarInfo[idx][cMod][7], //20
CarInfo[idx][cMod][8], //21
CarInfo[idx][cMod][9], //22
CarInfo[idx][cDonate], //23
CarInfo[idx][cInsure], //24
CarInfo[idx][cTrunkWep][1], //25
CarInfo[idx][cTrunkAmmo][1], //26
CarInfo[idx][cTrunkWep][2], //27
CarInfo[idx][cTrunkAmmo][2], //28
CarInfo[idx][cTrunkWep][3], //29
CarInfo[idx][cTrunkAmmo][3], //30
CarInfo[idx][cTrunkWep][4], //31
CarInfo[idx][cTrunkAmmo][4], //32
CarInfo[idx][cTrunkArmour], //33
CarInfo[idx][cTrunkCounter], //34
CarInfo[idx][cAlarm], //35
CarInfo[idx][cTrunkPot], //36
CarInfo[idx][cTrunkCrack], //37
CarInfo[idx][cTrunkMatsa], //38
CarInfo[idx][cTrunkMatsb], //39
CarInfo[idx][cTrunkMatsc], //40
CarInfo[idx][cImpounded], //41
CarInfo[idx][cImpoundedPrice], //42
CarInfo[idx][cDestroys], //43
CarInfo[idx][cInsurePrice]); //44
fwrite(file2, coordsstring);
idx++;
}
fclose(file2);
}
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[800]; // 0 1 2 4 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i,%i,%i,%i,%d,%d\n",
CarInfo[idx][cModel], // 0
CarInfo[idx][cLocationx], // 1
CarInfo[idx][cLocationy], // 2
CarInfo[idx][cLocationz], // 3
CarInfo[idx][cAngle], //4
CarInfo[idx][cColorOne], //5
CarInfo[idx][cColorTwo], //6
CarInfo[idx][cOwner], //7
CarInfo[idx][cDescription], //8
CarInfo[idx][cValue], //9
CarInfo[idx][cPlate], //10
CarInfo[idx][cOwnedCar], //11
CarInfo[idx][cLock], //12
CarInfo[idx][cMod][0], //13
CarInfo[idx][cMod][1], //14
CarInfo[idx][cMod][2], //15
CarInfo[idx][cMod][3], //16
CarInfo[idx][cMod][4], //17
CarInfo[idx][cMod][5], //18
CarInfo[idx][cMod][6], //19
CarInfo[idx][cMod][7], //20
CarInfo[idx][cMod][8], //21
CarInfo[idx][cMod][9], //22
CarInfo[idx][cDonate], //23
CarInfo[idx][cInsure], //24
CarInfo[idx][cTrunkWep][1], //25
CarInfo[idx][cTrunkAmmo][1], //26
CarInfo[idx][cTrunkWep][2], //27
CarInfo[idx][cTrunkAmmo][2], //28
CarInfo[idx][cTrunkWep][3], //29
CarInfo[idx][cTrunkAmmo][3], //30
CarInfo[idx][cTrunkWep][4], //31
CarInfo[idx][cTrunkAmmo][4], //32
CarInfo[idx][cTrunkArmour], //33
CarInfo[idx][cTrunkCounter], //34
CarInfo[idx][cAlarm], //35
CarInfo[idx][cTrunkPot], //36
CarInfo[idx][cTrunkCrack], //37
CarInfo[idx][cTrunkMatsa], //38
CarInfo[idx][cTrunkMatsb], //39
CarInfo[idx][cTrunkMatsc], //40
CarInfo[idx][cImpounded], //41
CarInfo[idx][cImpoundedPrice], //42
CarInfo[idx][cDestroys], //43
CarInfo[idx][cInsurePrice]); //44
if(idx == 0)
{
file2 = fopen("cars.cfg", io_write);
}
else
{
file2 = fopen("cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
}
Yes, it keep opening the folder and thats why its lagging, but how to make it open just once?
|
new File: file2 = fopen("cars.cfg", io_write);
if (!file2) return; // couldn't open file, stop right here
// loop...
fclose(file2);
if(idx == 0)
{
file2 = fopen("cars.cfg", io_write);
}
else
{
file2 = fopen("cars.cfg", io_append);
}
fclose(file2);
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(CarInfo))
{
new coordsstring[800]; // 0 1 2 4 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i,%i,%i,%i,%d,%d\n",
CarInfo[idx][cModel], // 0
CarInfo[idx][cLocationx], // 1
CarInfo[idx][cLocationy], // 2
CarInfo[idx][cLocationz], // 3
CarInfo[idx][cAngle], //4
CarInfo[idx][cColorOne], //5
CarInfo[idx][cColorTwo], //6
CarInfo[idx][cOwner], //7
CarInfo[idx][cDescription], //8
CarInfo[idx][cValue], //9
CarInfo[idx][cPlate], //10
CarInfo[idx][cOwnedCar], //11
CarInfo[idx][cLock], //12
CarInfo[idx][cMod][0], //13
CarInfo[idx][cMod][1], //14
CarInfo[idx][cMod][2], //15
CarInfo[idx][cMod][3], //16
CarInfo[idx][cMod][4], //17
CarInfo[idx][cMod][5], //18
CarInfo[idx][cMod][6], //19
CarInfo[idx][cMod][7], //20
CarInfo[idx][cMod][8], //21
CarInfo[idx][cMod][9], //22
CarInfo[idx][cDonate], //23
CarInfo[idx][cInsure], //24
CarInfo[idx][cTrunkWep][1], //25
CarInfo[idx][cTrunkAmmo][1], //26
CarInfo[idx][cTrunkWep][2], //27
CarInfo[idx][cTrunkAmmo][2], //28
CarInfo[idx][cTrunkWep][3], //29
CarInfo[idx][cTrunkAmmo][3], //30
CarInfo[idx][cTrunkWep][4], //31
CarInfo[idx][cTrunkAmmo][4], //32
CarInfo[idx][cTrunkArmour], //33
CarInfo[idx][cTrunkCounter], //34
CarInfo[idx][cAlarm], //35
CarInfo[idx][cTrunkPot], //36
CarInfo[idx][cTrunkCrack], //37
CarInfo[idx][cTrunkMatsa], //38
CarInfo[idx][cTrunkMatsb], //39
CarInfo[idx][cTrunkMatsc], //40
CarInfo[idx][cImpounded], //41
CarInfo[idx][cImpoundedPrice], //42
CarInfo[idx][cDestroys], //43
CarInfo[idx][cInsurePrice]); //44
new File: file2 = fopen("cars.cfg", io_write);
if (!file2) return; // couldn't open file, stop right here
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
}