Fuel system
#1

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

PHP код:
LoadDynamicFuelStations()
{
    new 
arrCoords[7][64];
    new 
strFromFile2[256];
    new 
Filefile fopen("dynamicfuelstations.cfg"io_read);
    if (
file)
    {
        new 
idx;
        while (
idx sizeof(FUELdata))
        {
            
fread(filestrFromFile2);
            
splits(strFromFile2arrCoords'|');
              
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],
        
FilefHandle fopen("dynamicfuelstations.cfg"io_write);
    for(new 
iIndexiIndex MAX_FUELSTATIONSiIndex++)
    {
        
format(szFileStrsizeof(szFileStr), "%d|%d|%f|%f|%f\r\n",
            
FUELdata[iIndex][fuelVW],
            
FUELdata[iIndex][fuelInt],
            
FUELdata[iIndex][fuelPosX],
            
FUELdata[iIndex][fuelPosY],
            
FUELdata[iIndex][fuelPosZ]
        );
        
fwrite(fHandleszFileStr);
    }
    return 
fclose(fHandle);

its does not seem to make its .cfg on its own
Reply
#2

You ned to use fCreate("Directory");

And fexist("directory") to check of the file exists if not create it. I'd wrote it for you but my phone keeps deleting it.
Reply
#3

how to use those? and i made a thingy that defines how much ids can the system store #define MAX_FUELSTATIONS... something like that
Reply
#4

As I said I cannot show you I'm on my phone as its self explanatory really.. Check the SAMP Wiki
Reply
#5

no if any other people can help me since that i don't really get the wiki
Reply
#6

Your just damn lazy, if fexist(directory) this else code!

pawn Код:
if(!fexist("MyFolder/myfile.ini"))
{
    fcreate("MyFolder/Myfile.ini");
    // code
}
Else
{
    //code
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)