06.06.2009, 03:45
Quote:
Originally Posted by efeX
Great idea, i'll do that.
Thanks! |
1) To convert normal car spawns or w.e like CreateVehicleEx(..) I just made a second function like CreateVehicleFile(with the same stuff as the normal) and the stock just takes all the information and puts it into the file

2) When spawning the cars I use a timer of 2 ms to loop through (as I found anything lower or a loop causes the server to lock up) But i've been fine running a 24/7 server using a 2 second timer loop. Maybe this has something to do with RAM, you might need to adjust it.
3) I also have a master list in the Cars folder called Main.ini
Inside it just has the total amount of vehicles and then a list of each vehicle ID's name
ex. first few lines:
VNUM=372
CarsLoaded=1
Car1=Greenwood
Car2=Greenwood
Car3=Mesa
Car4=Mesa
Car5=Clover
Car6=PCJ-600
Car7=PCJ-600
Car8=PCJ-600
Car9=PCJ-600
Car10=Boxville
Car11=Boxville
Car12=Boxville
4) If it helps here is my LoadCars public which I call after half a second of the Cars filterscript loading. You can refer to it if you run into any trouble

pawn Код:
public LoadCars()
{
if(dini_Int("Vehicles/Main.ini","CarsLoaded") == 1)
{
UnloadCars();
return 1;
}
new VNumber = dini_Int("Vehicles/Main.ini", "VNUM") + 1;
if(Cars == VNumber)
{
goto CarDone;
}
else
{
new Lol1[30];
new Float:X,Float:Y,Float:Z,Model,Float:Angle,Color1,Color2;
format(Lol1, sizeof(Lol1), "Vehicles/%i.ini",Cars);
if(dini_Exists(Lol1))
{
Model = dini_Int(Lol1, "Model");
X = dini_Float(Lol1, "X");
Y = dini_Float(Lol1, "Y");
Z = dini_Float(Lol1, "Z");
Angle = dini_Float(Lol1, "Angle");
Color1 = dini_Int(Lol1, "Color1");
Color2 = dini_Int(Lol1, "Color2");
CreateVehicle(Model, X, Y, Z, Angle, Color1, Color2, 300);
dini_IntSet(Lol1, "Spawned",1);
}
Cars = Cars + 1;
SetTimer("LoadCars", 2, 0);
//LoadCars();
return 1;
}
CarDone:
dini_IntSet("Vehicles/Main.ini","CarsLoaded",1);
Cars = 0;
print("\n\nCars Loaded");
print("\n\nChecking For Unspawned Cars...");
CarCheck();
return 1;
}
By the way, a nice thing about storing all cars on file is the ease of adding new cars and changing things
Like you can add a new car that will always spawn every time you start your server by making a command
or you can change a vehicle model or a paintjob without ever leaving game.
This means no running in and out of game to your script and messing with colors and such. Less fuss.
Come to think of it maybe I will release the script, i'll think about it.
Good luck!
-Mike