04.05.2013, 15:23
i dont get it..... on my way to making a fuel system i have encountered this but i don't exactly know whats wrong with it
its does not seem to make its .cfg on its own
PHP код:
LoadDynamicFuelStations()
{
new arrCoords[7][64];
new strFromFile2[256];
new File: file = fopen("dynamicfuelstations.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(FUELdata))
{
fread(file, strFromFile2);
splits(strFromFile2, arrCoords, '|');
FUELdata[idx][fuelVW] = strval(arrCoords[0]);
FUELdata[idx][fuelInt] = strval(arrCoords[1]);
FUELdata[idx][fuelPosX] = floatstr(arrCoords[2]);
FUELdata[idx][fuelPosY] = floatstr(arrCoords[3]);
FUELdata[idx][fuelPosZ] = floatstr(arrCoords[4]);
idx++;
}
fclose(file);
}
return 1;
}
SaveDynamicFuelStations()
{
new
szFileStr[326],
File: fHandle = fopen("dynamicfuelstations.cfg", io_write);
for(new iIndex; iIndex < MAX_FUELSTATIONS; iIndex++)
{
format(szFileStr, sizeof(szFileStr), "%d|%d|%f|%f|%f\r\n",
FUELdata[iIndex][fuelVW],
FUELdata[iIndex][fuelInt],
FUELdata[iIndex][fuelPosX],
FUELdata[iIndex][fuelPosY],
FUELdata[iIndex][fuelPosZ]
);
fwrite(fHandle, szFileStr);
}
return fclose(fHandle);
}