Unspawn all cars -
HondaCBR - 06.04.2012
I have car system and cars save to file 1000.txt, 1001.txt and so on.....
First line in that file is Spawned=0/1
I want a command which will unspawn all of them basically when you type /unspawnallcars It will check through every file, starting at 1000, and change the line to Spawned=0, thats all I want, dont worry about destroying the car, for now I just want to know how I can change first line in each file to =0.
Re: Unspawn all cars -
antonio112 - 06.04.2012
What file saving system you use ? Y_Ini ?
Re: Unspawn all cars -
HondaCBR - 06.04.2012
Thats some of the saving code:
Dini
pawn Код:
new CarFile2[35];
format(CarFile2,sizeof(CarFile2),"Cars/%d.ini",PlayerInfo[playerid][pCarKey1]);
if(dini_Int(CarFile2,"Spawned") == 1)
{
Re: Unspawn all cars -
antonio112 - 06.04.2012
I never used DINI so I can't give you the exact thing but you can try do it .. Count how many vehicles you have and do a X times loop, where X = number of vehicles you have.
Then, format a string to open the X file of vehicle and if it exist, open it and change whatever you want from it.
pawn Код:
new str[50], count = 0;
for(new i = 1000, i<1050, i++) // We take you have 50 vehicles
{
format(str, sizeof str, "/Vehicles/%i.ini", i); // Here you format the string, with the file location.
if(fexist(str))
{
// Here should come the open file and change the variable you want. But I don't know DINI, I can't exactly give you the code
count ++;
}
printf("%i vehicles changed.", count);
}
I used i = 1000 because you said your vehicles path is like 1001, 1002, 1003, etc etc, correct ?
Something like this should be.
Re: Unspawn all cars -
HondaCBR - 06.04.2012
Yes that right, could you just add the bit which changes the Spawned=0/1 line
Re: Unspawn all cars -
Ash. - 06.04.2012
Quote:
Originally Posted by HondaCBR
Yes that right, could you just add the bit which changes the Spawned=0/1 line
|
pawn Код:
dini_IntSet([file], "Spawned", 0);
I would assume.
Re: Unspawn all cars -
HondaCBR - 06.04.2012
It doesnt matter what I use, I used q, then I used blablabla, and it comes up with same errors but with q/blabla this time.
And how could I define it so the MAX value will be how many cars there is, i<count or something?
Re: Unspawn all cars -
HondaCBR - 06.04.2012
Ok fixed it
pawn Код:
for(new i = 1000; i<1050; i++)
But still 1 question remainging, i<1050, can I not change it to i<count or something, so it checks the numer of vehicles that are in that folder
Re: Unspawn all cars -
antonio112 - 06.04.2012
Yes, I told you. For example, if you have 150 vehicle files, you'd use i < 1150 ... Since the count starts from 1000, that means 150 vehicle files will get checked.
Re: Unspawn all cars -
HondaCBR - 06.04.2012
but I dont know how many vehicles I have, they add when you buy a vehicle so there is more every time, so I wanted something that counts them and uses that as MAX so I dont have to change it all the time.