File isn't creating... -
milanosie - 02.02.2012
Hello there, I have a weird thing.
I have a code for /createcar, it should create a file.
It doesn't
The car spawns and stuff, but the file does not create.
pawn Код:
CMD:createcar(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 6)
{
new Float:px, Float:py, Float:pz, Float:angle;
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, px, py, pz);
new vkol1;
new vkol2;
new vmodel;
new vehicprice;
new v;
if(!sscanf(params, "iiii", vmodel, vkol1, vkol2, vehicprice))
{
new string[128];
v = Index[topnumber] + 1;
format(file4,sizeof(file4), "vehicles/%d.ini", v);
dini_Create(file4);
dini_IntSet(file4, "model", CarInfo[v][model] = vmodel);
dini_IntSet(file4, "owner", CarInfo[v][owner] = 1);
dini_IntSet(file4, "forsale",CarInfo[v][forsale] = 1);
dini_FloatSet(file4, "vehx",px);
dini_FloatSet(file4, "vehy",py);
dini_FloatSet(file4, "vehz",pz);
dini_FloatSet(file4, "rot",angle);
dini_IntSet(file4, "vcol1",CarInfo[v][vcol1] = vkol1);
dini_IntSet(file4, "vcol2",CarInfo[v][vcol2] = vkol2);
dini_IntSet(file4, "CarLock",CarInfo[v][CarLock] = 0);
dini_IntSet(file4, "Vehprice",CarInfo[v][Vehprice] = vehicprice);
ownablecar = CreateVehicle(CarInfo[v][model], dini_Float(file4, "vehx"), dini_Float(file4, "vehy"), dini_Float(file4, "vehz"), dini_Float(file4, "rot"), CarInfo[v][vcol1], CarInfo[v][vcol2], 600000000000);
vehiforsale[ownablecar] = CarInfo[v][forsale];
vehiprice[ownablecar] = CarInfo[v][Vehprice];
vehilocked[ownablecar] = 0;
Index[topnumber] = Index[topnumber] + 1;
format(string, sizeof(string), "Price: %d\nUse /buycar to buy this vehicle!",CarInfo[v][Vehprice]);
VehicleLabel[v] = Create3DTextLabel(string ,COLOR_ORANGE, dini_Float(file4, "vehx"),dini_Float(file4, "vehy"),dini_Float(file4, "vehz"),20, 0, 1);
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "USAGE: /createcar [Model ID] [Color 1] [Color 2] [Price]");
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command!");
}
what am I doing wrong?
Re: File isn't creating... -
Max_Coldheart - 02.02.2012
Where do you define the variable File4?
Re: File isn't creating... -
milanosie - 02.02.2012
On top of my script, File4 is completly defined
I used it before, but changed the code into something else, so its not something with defining.
Re: File isn't creating... -
Jefff - 02.02.2012
Dont use Dini for that
pawn Код:
CMD:createcar(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 6)
{
new Float:px, Float:py, Float:pz, Float:angle;
GetPlayerPos(playerid, px, py, pz);
GetPlayerFacingAngle(playerid, angle);
new vkol1;
new vkol2;
new vmodel;
new vehicprice;
new v;
if(!sscanf(params, "iiii", vmodel, vkol1, vkol2, vehicprice))
{
new string[128];
v = Index[topnumber] + 1;
format(file4,sizeof(file4), "/vehicles/%d.ini", v);
new File:Cars = fopen(file4,io_write);
format(string,sizeof(string),"\
model=%d\r\n \
owner=1\r\n \
forsale=1\r\n \
vehx=%.4f\r\n \
vehy=%.4f\r\n \
vehz=%.4f\r\n \
rot=%.4f\r\n \
vcol1=%d\r\n \
vcol2=%d\r\n \
CarLock=0\r\n \
Vehprice=%d\r\n",vmodel,px,py,pz,angle,vkol1,vkol2,vehicprice);
fwrite(Cars,string);
fclose(Cars);
CarInfo[v][model] = vmodel;
CarInfo[v][owner] = 1;
CarInfo[v][forsale] = 1;
CarInfo[v][vcol1] = vkol1;
CarInfo[v][vcol2] = vkol2;
CarInfo[v][CarLock] = 0;
CarInfo[v][Vehprice] = vehicprice;
ownablecar = CreateVehicle(CarInfo[v][model], px, py, pz, angle, CarInfo[v][vcol1], CarInfo[v][vcol2], 600000000000);
vehiforsale[ownablecar] = CarInfo[v][forsale];
vehiprice[ownablecar] = CarInfo[v][Vehprice];
vehilocked[ownablecar] = 0;
Index[topnumber] = Index[topnumber] + 1;
format(string, sizeof(string), "Price: %d\nUse /buycar to buy this vehicle!",CarInfo[v][Vehprice]);
VehicleLabel[v] = Create3DTextLabel(string ,COLOR_ORANGE, px, py, pz, 20, 0, 1);
return 1;
}
else return SendClientMessage(playerid, COLOR_GREY, "USAGE: /createcar [Model ID] [Color 1] [Color 2] [Price]");
}
else return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command!");
}
Re: File isn't creating... -
milanosie - 02.02.2012
Thanks but fixed it, dini workes fine btw,
Makes no sense to not use it.
was a silly mistake...
Forgot to make the topnumber file
Re: File isn't creating... -
milanosie - 02.02.2012
ow btw ******, Thanks for helping me out over and over again
Thanks to your help I learned a lot about loops etc.
and with that I made a house + vehicle system