File format. -
Darnell - 04.09.2011
pawn Код:
public OnPropUpdate()
{
new idx;
new File: file2;
while (idx < sizeof(HouseInfo)) {
new coordsstring[255];
format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n\r",
HouseInfo[idx][hEntrancex],
HouseInfo[idx][hEntrancey],
HouseInfo[idx][hEntrancez],
HouseInfo[idx][hExitx],
HouseInfo[idx][hExity],
HouseInfo[idx][hExitz],
HouseInfo[idx][hHealthx],
HouseInfo[idx][hHealthy],
HouseInfo[idx][hHealthz],
HouseInfo[idx][hArmourx],
HouseInfo[idx][hArmoury],
HouseInfo[idx][hArmourz],
HouseInfo[idx][hOwner],
HouseInfo[idx][hDiscription],
HouseInfo[idx][hValue],
HouseInfo[idx][hHel],
HouseInfo[idx][hArm],
HouseInfo[idx][hInt],
HouseInfo[idx][hLock],
HouseInfo[idx][hOwned],
HouseInfo[idx][hRooms],
HouseInfo[idx][hRent],
HouseInfo[idx][hRentabil],
HouseInfo[idx][hTakings],
HouseInfo[idx][hVec],
HouseInfo[idx][hVcol1],
HouseInfo[idx][hVcol2],
HouseInfo[idx][hDate],
HouseInfo[idx][hLevel],
HouseInfo[idx][hWorld],
HouseInfo[idx][hOutWorld],
HouseInfo[idx][hOutInt],
HouseInfo[idx][hOTaken]);
HouseInfo[idx][hWorld] = idx;
if(idx == 0) {
file2 = fopen("cfgs/property.cfg", io_write);
}
else {
file2 = fopen("cfgs/property.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
As you see, I've got this code above, and it saves it by each line and formatting it.
But each time that someone moves a house ingame, in the property.cfg, it's getting messy.
Any reason ?
Re: File format. -
=WoR=Varth - 04.09.2011
What do you mean by messy?
Re: File format. -
Darnell - 04.09.2011
It doesn't make everything in lines, everything is together.
Re: File format. -
Improvement™ - 04.09.2011
Quote:
Originally Posted by Darnell
It doesn't make everything in lines, everything is together.
|
Maybe that's because of this line?
pawn Код:
new coordsstring[255];
format(coordsstring, sizeof(coordsstring), "%f,%f,%f,%f,%f,%f,%d,%d,%d,%d,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n\r",
Or do you mean something else by "Everything is together"?
Re: File format. -
=WoR=Varth - 04.09.2011
You mean you want to write them in each lines?
Use "\n" instead "," then.
Re: File format. -
Darnell - 04.09.2011
You probabrly didn't understood.
In the file, I write it like this for example.
Код:
-2087.8040,2478.4866,48.3979,-2077.9951,2476.3862,41.9455,0,0,0,0,0,0,The State,Mansion,1,0,0,0,1,0,3,0,0,0,0,0,0,0,2
-2077.9951,2266.5142,5.4755,1267.663208,-781.323242,1091.906250,0,0,0,0,0,0,The State,Mansion,1,0,0,5,1,0,3,0,0,0,0,0,0,0,2
But then, if someone moves it, it's like that.
Код:
-2087.8040,2478.4866,48.3979,-2077.9951,2476.3862,41.9455,0,0,0,0,0,0,The State,Mansion,1,0,0,0,1,0,3,0,0,0,0,0,0,0,2-2077.9951,2266.5142,5.4755,1267.663208,-781.323242,1091.906250,0,0,0,0,0,0,The State,Mansion,1,0,0,5,1,0,3,0,0,0,0,0,0,0,2
Re: File format. -
Jack_Leslie - 04.09.2011
What's the command for when someone moves a house or whatever?
Re: File format. -
Darnell - 04.09.2011
/houseentrance, in this case.
pawn Код:
if(strcmp(cmd, "/houseentrance", true) == 0) {
if(IsPlayerConnected(playerid)) {
if (PlayerInfo[playerid][pAdmin] < 10) {
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /houseentrance [houseid] - Moves a house to you");
return 1;
}
new proplev = strval(tmp);
if(proplev > sizeof(HouseInfo) || proplev < 0) {
SendClientMessage(playerid,COLOR_WHITE,"House ID must be above 0 and below 33");
return 1;
}
else {
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
format(string,sizeof(string),"Entrance of House %d to %f - %f - %f",proplev,X,Y,Z);
ABroadCast(COLOR_YELLOW,string,5);
HouseInfo[proplev][hEntrancex] = X;
HouseInfo[proplev][hEntrancey] = Y;
HouseInfo[proplev][hEntrancez] = Z;
OnPropUpdate();
return 1;
}
}
}
Re: File format. -
Jack_Leslie - 04.09.2011
Try using "\r\n" instead of just "\n"
Re: File format. -
Darnell - 04.09.2011
Much love Jack, repped.