Help with a vehicle system
#1

Hi, I am making a vehicle system when I just realised that I have no idea how I am going to resolve this issue:

When you create a vehicle, it gets the vehicle ID and stores it as the title of the file. So vehicle ID 30 will be 30.ini in the Vehicles folder in scriptfiles. So, lets say I remove vehicle ID 29, meaning the old vehicle ID 30 will move to ID 29 on the server restart. It will be looking for the information from the 29.ini although all the info is saved in 30.ini. How could I resolve this so the vehicles ID will always be the same as its file title?

If this confuses you I will explain it simpler if need be.

All help is appreciated.

-Conroy
Reply
#2

If "remove vehicleid 29" means removing it from OnGameModeInit manually, you need to rename the "30.ini" to
"29.ini" manually as well.
Because the compiler doesn't keep record of the vehicle that "was" created with the same ID and then doesn't look for that id's file.
And if you are talking about removing the vehicle as in "DestroyVehicle", then the id's won't change untill restart anyways.

EDIT: I'd suggest you use the owner's name or anything other than vehicle id's since they tend to change.
Reply
#3

Alright, but I would also have an issue with that.

I created vehicles at the start of the gamemode, which do not have an owner, how could I save those?

Ex: ForSale1, ForSale2, ForSale3 etc etc, how could I get the next unused number?

-Conroy

EDIT:

I tried this:

pawn Код:
stock ReturnNextSaleVehicleFileName()
{
    new filename[40], i, filenumber[40], lastint;
    while(ffind("\\Vehicles\\ForSale*.ini", filename, 64, i)) {
        strmid(filenumber, filename, 19, sizeof(filename));
        if(strval(filenumber) > lastint) lastint = strval(filenumber);
    }
    return lastint;
}
But it always returns 0, even with ForSale0.ini already created. Any ideas?
Reply
#4

edit. woops. nvm wont workk
Reply
#5

Fixed the problem. filename only stores the name, not the full directory.

Ex: \\Vehicles\\ForSale0001.ini would save as ForSale0001.ini. After I knew that I changed the length of the strmid.

Thanks to all who helped,

-Conroy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)