LoadVehicles || Own scratch made vehicles Ownership help. -
ricardo178 - 15.02.2012
Hello. I am creating my own vehicles ownership from scratch. Milanosie is helping me much, but i am too noob to understand and he also has his own scripts to do as owner of the great server i play.
So i am asking you some help. :P
I created the /createvehicle command, and it saves the car, create it, a text label all right.
It creates 1 file for each car.
But i don't know how to make all cars load from the file on server restart.....
The /createvehicle cmd:
pawn Код:
CMD:createvehicle(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 5)
{
new Float:px, Float:py, Float:pz, Float:angle, vkol1, vkol2, vmodel, vprice, v, string[128];
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, px, py, pz);
if(!sscanf(params, "iiii", vmodel, vkol1, vkol2, vprice))
{
v = VehicleInfo[topnumber]+1;
format(file, sizeof(file), "RRP/vehicles/%d.ini", v);
dini_Create(file);
dini_FloatSet(file, "X", Float:px);
dini_FloatSet(file, "Y", Float:py);
dini_FloatSet(file, "Z", Float:pz);
dini_FloatSet(file, "A", Float:angle);
dini_IntSet(file, "Model", vmodel);
dini_IntSet(file, "Color1", vkol1);
dini_IntSet(file, "Color2", vkol2);
dini_IntSet(file, "Price", vprice);
CreateVehicle(vmodel, Float:px, Float:py, Float:pz, Float:angle, vkol1, vkol2, 86400);
format(string, sizeof(string), "This vehicle is for sale. Price: %d", vprice);
Create3DTextLabel(string, COLOR_RED, Float:px, Float:py, Float:pz, 10.0, 0, 0);
VehicleInfo[topnumber] = VehicleInfo[topnumber]+1;
format(file, sizeof(file), "RRP/vehicles/Vindex.ini");
if(fexist(file))
{
dini_IntSet(file, "topnumber", VehicleInfo[topnumber]);
}
return 1;
}
else return SendClientMessage(playerid, COLOR_DARKGOLD, "USAGE: /createcar [Model ID] [Color 1] [Color 2] [Price]");
}
else return NotAdmin(playerid);
}
THANK YOU.
Re: LoadVehicles || Own scratch made vehicles Ownership help. -
PrawkC - 16.02.2012
And you're scripting for money..
Anyways, you could easily have looked at another script.. but what you can do assuming you save the cars like 1.ini, 2.ini, 3.ini etc.. you create a LoadVehicle stock ro what not and do a for loop, and loop through all the files in the folder and then assign all the values from the file to the value in the script, IE,
dini_FloatSet(file, "Z", Vehicle[vehicleCount][PosZ]);
etc... increment vehicleCount each time the for loop goes through.
Re : LoadVehicles || Own scratch made vehicles Ownership help. -
ricardo178 - 16.02.2012
Done it, and it works perfectly and dynamicaly. :P Just made it alone.
Thank you for help.
P.S. Yes i script for money and all clients are satisfied.. I only accept requests to things i know how to make. That's why it says "Little scripts".. Actualy making a gamemode, enterly by scratch to learn more.