24.01.2012, 14:34
So, I am *trying* to make a car ownership..
Its going 50/50...
Sometimes Im sitting here with the hands in my hair like "AAARGGG"
Now, I made it so that the car info ( model, color, coordinates etc.. ) save in a file called 1.ini, 2.ini, 3.ini etc...
Now, How to create a car every time the server starts?
Not just one car. All cars that exist..
is this possible?(it should be..)
And if yes, how or what direction should I go.
some piece of code I have for loading(it is probably entirly wrong but whatever..)
This is the code for the Buying(and setting car info)
Anyone have an idea?
Its going 50/50...
Sometimes Im sitting here with the hands in my hair like "AAARGGG"
Now, I made it so that the car info ( model, color, coordinates etc.. ) save in a file called 1.ini, 2.ini, 3.ini etc...
Now, How to create a car every time the server starts?
Not just one car. All cars that exist..
is this possible?(it should be..)
And if yes, how or what direction should I go.
some piece of code I have for loading(it is probably entirly wrong but whatever..)
pawn Код:
{
for(new i = 1; i < MAX_VEHICLES; i++)
{
format(file4,sizeof(file4), "realityrp/vehicles/%d.ini", i);
if (!dini_Exists(file4))
{
format(file4,sizeof(file4), "realityrp/vehicles/%d.ini", i);
CarInfo[i][model] = dini_Int(file4, "model");
CarInfo[i][owner] = dini_Int(file4, "owner");
CarInfo[i][forsale] = dini_Int(file4, "forsale");
CarInfo[i][vehx] = dini_Int(file4, "vehx");
CarInfo[i][vehy] = dini_Int(file4, "vehy");
CarInfo[i][vehz] = dini_Int(file4, "vehz");
CarInfo[i][rot] = dini_Int(file4, "rot");
CarInfo[i][vcol1] = dini_Int(file4, "vcol1");
CarInfo[i][vcol2] = dini_Int(file4, "vcol2");
new modv = dini_Int(file4, "model");
new flx = dini_Int(file4, "vehx");
new fly = dini_Int(file4, "vehy");
new flz = dini_Int(file4, "vehz");
new flr = dini_Int(file4, "rot");
new fc1 = dini_Int(file4, "vcol1");
new fc2 = dini_Int(file4, "vcol2");
PrCar[CarID] = CreateVehicle(modv, flx, fly, flz, flr, fc1, fc2, 6000000);
return 1;
}
}
return 1;
}
pawn Код:
new vehc = GetPlayerVehicleID(playerid);
new vehmod = GetVehicleModel(vehc);
new ownedcar;
format(file9,sizeof(file9),"realityrp/vehicles/Vindex.ini");
PlayerInfo[playerid][Vehkey] = PlayerInfo[playerid][Vehkey] + 1;
GivePlayerMoney(playerid, - vehmod);
dini_IntSet(file9, "topnumber",Index[topnumber] = Index[topnumber] + 1);
format(file4,sizeof(file3), "realityrp/vehicles/%d.ini", Index[topnumber] + 1);
dini_Create(file4);
dini_IntSet(file4, "model", CarInfo[Pcar][model] = vehmod);
dini_IntSet(file4, "owner", CarInfo[Pcar][owner] = PlayerInfo[playerid][Pid]);
dini_IntSet(file4, "forsale",CarInfo[Pcar][forsale] = 0);
dini_IntSet(file4, "vehx",CarInfo[Pcar][vehx] = -1580);
dini_IntSet(file4, "vehy",CarInfo[Pcar][vehy] = 106);
dini_IntSet(file4, "vehz",CarInfo[Pcar][vehz] = 4);
dini_IntSet(file4, "rot",CarInfo[Pcar][rot] = 90);
dini_IntSet(file4, "vcol1",CarInfo[Pcar][vcol1] = 0);
dini_IntSet(file4, "vcol2",CarInfo[Pcar][vcol2] = 0);
SendClientMessage(playerid, COLOR_GREEN, "You bought a car! its at San Fierro Docks");
PrCar[CarID] = CreateVehicle(CarInfo[Pcar][model],CarInfo[Pcar][vehx],CarInfo[Pcar][vehy],CarInfo[Pcar][vehz],CarInfo[Pcar][rot],CarInfo[Pcar][vcol1],CarInfo[Pcar][vcol2],30000000);
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);