SA-MP Forums Archive
Fuel system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Fuel system (/showthread.php?tid=434867)



Fuel system - Ryan_Obeles - 04.05.2013

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


Re: Fuel system - IceCube! - 04.05.2013

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.


Re: Fuel system - Ryan_Obeles - 04.05.2013

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


Re: Fuel system - IceCube! - 04.05.2013

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


Re: Fuel system - Ryan_Obeles - 04.05.2013

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


Re: Fuel system - IceCube! - 04.05.2013

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

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