SA-MP Forums Archive
Question about consecutive files - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Question about consecutive files (/showthread.php?tid=448408)



Question about consecutive files - MMickey - 04.07.2013

Hy, i had a question about the consecutive files..

I mean..my car ownership is normal..or something like that..every ownable car, saves in specific file..
Код:
1.ini 2.ini 3.ini 4.ini 5.ini 6.ini 7.ini etc...
when i use /v buy
If i use /v sell, the car that is in a file
Код:
e.g. 5.ini
is removed..so that create me a bug..
Is possible, when i buy a car, to check what file is missing..and replace that file..?
At me, when i buy a car, and i have:

Код:
1.ini 2.ini 3.ini 4.ini 6.ini 7.ini etc..
The command create me
Код:
8.ini
not 5.ini ...

So..it is possible to do this ?




Re: Question about consecutive files - MMickey - 05.07.2013

I offer rep++


Re: Question about consecutive files - SuperViper - 05.07.2013

Use this to get the next available vehicle ID:

pawn Код:
for(new vehicleIndex, fileName[10]; vehicleIndex < MAX_VEHICLES; vehicleIndex++)
{
    format(fileName, sizeof(fileName), "%d.ini", vehicleIndex);

    if(!file_exists(fileName))
    {
        // Use the ID stored in vehicleIndex
        return 1;
    }
}

// No slots available