SA-MP Forums Archive
Help with command to remove file - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with command to remove file (/showthread.php?tid=85878)



Help with command to remove file - Jameston12 - 10.07.2009

Helllo,

I've got a question,
I've searched but found nothing that helps me.

Is it possible to remove a single line by searching for ID?

For example: I want to remove vehicle ID 34.
1
2
3
4
ect
ect
ect
34

So that when I do: /veh remove 34

It will remove ID 34 (not line because ID 34 might not be line 34).

I hope you understand what I want.

and I really hope you can help!

Greetings,
James.


Re: Help with command to remove file - lavamike - 10.07.2009

If I were you I would just use dini for it. But I'm sure it's possible, but I think it's pretty difficult.


Re: Help with command to remove file - Jameston12 - 10.07.2009

Well, I allready use Dini for my register system ect.
And i've tryed stuff myself but I couldnt get it to work even a little bit.

So I hope one of you alrleady done something like this.

I'm looking for something that loops the file searching for that ID in the first array cararray[0] < that is the ID.

Anyone got a suggestion?

EDIT:
how about something like this:

pawn Код:
public LoadVehicles()
{
    new carid;
    new File:fhandle,temp[256];
    fhandle = fopen("Cars/vehicles.cfg",io_read);
    while(fread(fhandle,temp,sizeof(temp),false))
    {
      sscanf(temp,"d", carid);
      if(removeid == carid){
           //here blabla to remove?
        }
    }
    fclose(fhandle);
    return 1;
}
This is just a REALLY rough idea, but would that work?


Re: Help with command to remove file - Jameston12 - 10.07.2009

He sorry to double post but ive gotten a bit further now.

Now I just need to delete a line, i found a few to find the line but not the number.

pawn Код:
public RemoveVehicle(id)
{
    new carid, vmodel, Float:x,Float:y,Float:z,Float:a,color1,color2;
    new File:fhandle,temp[256];
    fhandle = fopen("Cars/vehicles.cfg",io_read);
    while(fread(fhandle,temp,sizeof(temp),false))
    {
      sscanf(temp,"ddffffdd", carid, vmodel, x,y,z,a,color1,color2);
      if(id == carid){
        InfoMsgToAll("This is a car that needs to be deleted(this must be changed it something to remove the car");
        }
    }
    fclose(fhandle);
    return 1;
}
I hope you can help me now.