DINI don't save into %d.ini. Why? -
Vibrate17 - 09.03.2011
Hy everyone. I have a problem with personal cars system.
Код:
else if(strcmp(x_nr,"buy",true) == 0)
{
new car = 451;
new model = GetVehicleModel(idcar);
if(IsASalesVehicle(idcar))
{
if(PlayerInfo[playerid][pLevel] < 3)
{
SendClientMessage(playerid, COLOR_GREY, "You need to be level 3 to buy a vehicle!");
return 1;
}
if(PlayerInfo[playerid][pPcarkey] == 9999 || PlayerInfo[playerid][pPcarkey2] == 9999) { }
else return SendClientMessage(playerid, COLOR_GREY,"* You already own Two cars!");
if(GetPlayerCash(playerid) >= GetVehiclePrice(idcar))
{
if(PlayerInfo[playerid][pCarLic] == 1)
{
for(new h = 451; h < sizeof(CarInfo); h++)
{
if(CarInfo[h][cOwned] == 0)
{
car = h;
h = 9999;
}
}
format(string, sizeof(string),"Cars/%d.ini",car);
dini_Create(string);
if(PlayerInfo[playerid][pPcarkey] != 9999) { PlayerInfo[playerid][pPcarkey2] = car; }
else { PlayerInfo[playerid][pPcarkey] = car; }
CarInfo[car][cOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(CarInfo[car][cOwner], sendername, 0, strlen(sendername), 999);
GivePlayerCash(playerid,-GetVehiclePrice(idcar));
if(IsModelAPlane(idcar) || IsModelAHeli(idcar)) //
{
CarInfo[car][cLocationx] = 1760.7433;
CarInfo[car][cLocationy] = -2545.6406;
CarInfo[car][cLocationz] = 13.5469;
CarInfo[car][cAngle] = 83.1246;
SendClientMessage(playerid, COLOR_YELLOW2, "Avionul tau personal a fost spawnat prin apropiere!");
GameTextForPlayer(playerid, "~p~Felicitari~n~~w~Nu uita sa-ti ridici avionul rosu din apropiere!", 5000, 3);
}
else if(IsModelABoat(idcar))//
{
CarInfo[car][cLocationx] = 754.9165;
CarInfo[car][cLocationy] = -1919.8986;
CarInfo[car][cLocationz] = -0.5057;
CarInfo[car][cAngle] = 170.5105;
SendClientMessage(playerid, COLOR_YELLOW2, "Barca ta a fost spawnata prin apropiere!");
GameTextForPlayer(playerid, "~p~Felicitari~n~~w~Nu uita sa-ti ridici barca rosie din apropiere!", 5000, 3);
}
else if(IsPlayerInRangeOfPoint(playerid, 125, 2128.0864,-1135.3912,25.5855)) //
{
CarInfo[car][cLocationx] = 2133.7229;
CarInfo[car][cLocationy] = -1105.6392;
CarInfo[car][cLocationz] = 25.3727;
CarInfo[car][cAngle] = 69.9340;
SendClientMessage(playerid, COLOR_YELLOW2, "Masina ta a fost livrata peste drum. Te rog sa o ridici de acolo!");
GameTextForPlayer(playerid, "~p~Felicitari~n~~w~Nu uita sa-ti ridici masina rosie de peste drum!", 5000, 3);
}
else if(IsPlayerInRangeOfPoint(playerid, 125,770.8729,-1352.0680,13.5320)) //
{
CarInfo[car][cLocationx] = 747.2092;
CarInfo[car][cLocationy] = -1352.2577;
CarInfo[car][cLocationz] = 13.5000;
CarInfo[car][cAngle] = 274.2293;
SendClientMessage(playerid, COLOR_YELLOW2, "Masina ta a fost spawnata in aceasta parcare. Te rog sa o ridici!");
GameTextForPlayer(playerid, "~p~Felicitari~n~~w~Nu uita sa-ti ridici masina rosie din aceasta parcare!", 5000, 3);
}
else
{
CarInfo[car][cLocationx] = -1589.2644;
CarInfo[car][cLocationy] = 106.9119;
CarInfo[car][cLocationz] = 3.5495;
CarInfo[car][cAngle] = 317.1649;
SendClientMessage(playerid, COLOR_YELLOW2, "masina ta a fost spawnata la San Fierro Docks. Te rog sa o ridici!!");
GameTextForPlayer(playerid, "~p~Felicitari~n~~w~Nu uita sa-ti ridici masina rosie de la San Fierro Docks!", 5000, 3);
}
CarInfo[car][cModel] = model;
CarInfo[car][cVirWorld] = 0;
CarInfo[car][cPaintjob] = 999;
CarInfo[car][cColorOne] = 3;
CarInfo[car][cColorTwo] = 3;
CarInfo[car][cComponent0] = 0;
CarInfo[car][cComponent1] = 0;
CarInfo[car][cComponent2] = 0;
CarInfo[car][cComponent3] = 0;
CarInfo[car][cComponent4] = 0;
CarInfo[car][cComponent5] = 0;
CarInfo[car][cComponent6] = 0;
CarInfo[car][cComponent7] = 0;
CarInfo[car][cComponent8] = 0;
CarInfo[car][cComponent9] = 0;
CarInfo[car][cComponent10] = 0;
CarInfo[car][cComponent11] = 0;
CarInfo[car][cComponent12] = 0;
CarInfo[car][cComponent13] = 0;
DestroyVehicle(car);
ownedcar[car] = CreateVehicle(CarInfo[car][cModel],CarInfo[car][cLocationx],CarInfo[car][cLocationy],CarInfo[car][cLocationz],90.0,3,3,never);
PlayerPlayMusic(playerid);
SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclehelp to view the vehicle manual!");
VehicleInfo[playerid][Engine] = 0;
SendClientMessage(playerid, COLOR_GREY, "Remember to set the new Security Code of the Car!");
new pass[24];
format(pass, sizeof(pass),"%d%d%d",random(9),random(9),random(9));
CarInfo[car][cCode] = strval(pass);
OnPropUpdateIt();
OnPlayerDataSave(playerid);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you ! ");
return 1;
}
}
}
Код:
public OnPropUpdateIt()
{
new file3[26]
for(idx = 451; idx < sizeof(CarInfo); idx++)
{
format(file3, sizeof(file3),"Cars/%d.ini",idx);
if(dini_Exists(file3))
{
dini_IntSet(file3,"Model",CarInfo[idx][cModel]);
dini_FloatSet(file3,"Location_X",CarInfo[idx][cLocationx]);
dini_FloatSet(file3,"Location_Y",CarInfo[idx][cLocationy]);
dini_FloatSet(file3,"Location_Z",CarInfo[idx][cLocationz]);
dini_FloatSet(file3,"Angle",CarInfo[idx][cAngle]);
dini_IntSet(file3,"Color_1",CarInfo[idx][cColorOne]);
dini_IntSet(file3,"Color_2",CarInfo[idx][cColorTwo]);
dini_Set(file3,"Owner",CarInfo[idx][cOwner]);
dini_IntSet(file3,"Owned",CarInfo[idx][cOwned]);
dini_IntSet(file3,"Locked",CarInfo[idx][cLock]);
dini_IntSet(file3,"Paintjob",CarInfo[idx][cPaintjob]);
dini_IntSet(file3,"VirtualWorld",CarInfo[idx][cVirWorld]);
dini_IntSet(file3,"Component0",CarInfo[idx][cComponent0]);
dini_IntSet(file3,"Component1",CarInfo[idx][cComponent1]);
dini_IntSet(file3,"Component2",CarInfo[idx][cComponent2]);
dini_IntSet(file3,"Component3",CarInfo[idx][cComponent3]);
dini_IntSet(file3,"Component4",CarInfo[idx][cComponent4]);
dini_IntSet(file3,"Component5",CarInfo[idx][cComponent5]);
dini_IntSet(file3,"Component6",CarInfo[idx][cComponent6]);
dini_IntSet(file3,"Component7",CarInfo[idx][cComponent7]);
dini_IntSet(file3,"Component8",CarInfo[idx][cComponent8]);
dini_IntSet(file3,"Component9",CarInfo[idx][cComponent9]);
dini_IntSet(file3,"Component10",CarInfo[idx][cComponent10]);
dini_IntSet(file3,"Component11",CarInfo[idx][cComponent11]);
dini_IntSet(file3,"Component12",CarInfo[idx][cComponent12]);
dini_IntSet(file3,"Component13",CarInfo[idx][cComponent13]);
dini_IntSet(file3,"SecurityCode",CarInfo[idx][cCode]);
}
}
return 1;
}
What's wrong and why DINI don't save into %d.ini ?
Re: DINI don't save into %d.ini. Why? -
iggy1 - 09.03.2011
pawn Код:
format(file3, sizeof(file3),"Cars/carfile%d.ini",idx);
Try that i'm dont think the first digit in the filename can be a number, not sure but i dont think you can.
Re: DINI don't save into %d.ini. Why? -
Vibrate17 - 09.03.2011
First time was work, but before don't save and i don't know why. I have not made changes to this system.
PS : I have made this changes but still don't work.
Re: DINI don't save into %d.ini. Why? -
iggy1 - 09.03.2011
Are you sure the file that your trying to write to exists? Because your only saving to the file there 'if' it exists.
Eg,
pawn Код:
if(dini_Exists(file3))
{
dini_IntSet(file3,"Model",CarInfo[idx][cModel]);
dini_FloatSet(file3,"Location_X",CarInfo[idx][cLocationx]);
dini_FloatSet(file3,"Location_Y",CarInfo[idx][cLocationy]);
dini_FloatSet(file3,"Location_Z",CarInfo[idx][cLocationz]);
dini_FloatSet(file3,"Angle",CarInfo[idx][cAngle]);
dini_IntSet(file3,"Color_1",CarInfo[idx][cColorOne]);
}
else//file doesn't exist
{
dini_create(file3);//i dont think this is a dini function (i dont use dini)
//but you should get the idea
dini_IntSet(file3,"Model",CarInfo[idx][cModel]);
//...
}
Re: DINI don't save into %d.ini. Why? -
Vibrate17 - 09.03.2011
When I type command /v buy that file will be created and then OnPropUpdateIt() will be updated with new informations. It's somthing wrong?
PS : Don't work what are you say. When I login, the server shutdown.
Re: DINI don't save into %d.ini. Why? -
Vibrate17 - 09.03.2011
Solutions please?