Question about consecutive files
#1

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 ?

Reply
#2

I offer rep++
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)