Loop Through Lines and Delete One?
#8

It depends, if you save your vehicles as IDs (Vehicle_1.ini, and so on; that's what I recommend) and not by owner (it will limit you to owning only 1 vehicle), this code should be easy for you to understand.
You really do not require any loops but this:
pawn Код:
stock DeleteOwnedVehicle( key )
{
    new file_path[32];
    format( file_path, 32, "Vehicle_%d.ini", key ); // this is an example
    fremove( file_path );
    vehicleinfo[key][owned] = 0; // if your vehicle enum had the element 'owned' and your array 'vehicleinfo'
}
Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
I could do what you said above, but it wouldn't really be practical to have a file per car. I'll figure it out. I'm using sscanf, and the default file functions.
It is practical. It is more organized than one file with the owner name, and all the data for all the vehicles inside it.

Otherwise, if you save all the cars in one single file, check this:
Quote:
Originally Posted by SAMP Wiki
Reading Line-by-Line
pawn Код:
public OnPlayerConnect(playerid)
{
    new string[64]; // Create the string to store the read text in
    new File:example = fopen("Startup.txt", io_read); // Open the file
    while(fread(example, string)) //reads the file line-by-line
    {
        if(strcmp(string, "Ban", true) == 0) //if any of the lines in the file say "Ban" the system will ban the player
        {
            Ban(playerid); //bans the player
        }
    }
    fclose(example);
    return 1;
}
Modify it as you require.
Reply


Messages In This Thread
Loop Through Lines and Delete One? - by ReneG - 28.04.2012, 19:57
Re: Loop Through Lines and Delete One? - by The DeLuca - 28.04.2012, 20:22
Re: Loop Through Lines and Delete One? - by Jonny5 - 28.04.2012, 22:09
Re: Loop Through Lines and Delete One? - by Crazymax - 28.04.2012, 22:57
Re: Loop Through Lines and Delete One? - by The DeLuca - 28.04.2012, 23:11
Re: Loop Through Lines and Delete One? - by ReneG - 28.04.2012, 23:13
Re: Loop Through Lines and Delete One? - by The DeLuca - 28.04.2012, 23:15
Re: Loop Through Lines and Delete One? - by admantis - 28.04.2012, 23:24

Forum Jump:


Users browsing this thread: 1 Guest(s)