New files overwrite eachother
#5

Try this instead:

Код:
SaveHouses(houseid)
{
	new path[128];

	houseid++;
	format(path, 128, "Houses/%i.ini", houseid);

	new INI:HouseFile = INI_Open(path);
	INI_WriteString(HouseFile,"Owner", HouseInfo[houseid][hOwner]);
	INI_WriteString(HouseFile,"Description", HouseInfo[houseid][hDes]);
	INI_WriteInt(HouseFile,"Price", HouseInfo[houseid][hPrice]);
	INI_WriteInt(HouseFile,"Rent", HouseInfo[houseid][hRent]);
	INI_WriteInt(HouseFile,"World", HouseInfo[houseid][hWorld]);
	INI_WriteInt(HouseFile,"Interior", HouseInfo[houseid][hInterior]);
	INI_WriteFloat(HouseFile,"X", HouseInfo[houseid][hX]);
	INI_WriteFloat(HouseFile,"Y", HouseInfo[houseid][hY]);
	INI_WriteFloat(HouseFile,"Z", HouseInfo[houseid][hZ]);
	INI_WriteFloat(HouseFile,"A", HouseInfo[houseid][hA]);
	INI_Close(HouseFile);

	print("Houses saved");

	return 1;
}
There is no need to check if your housefile already exists for saving.
If it doesn't exist, it will be created.
If it does exist, it will get overwritten.

Is the HouseID++ needed? You can also delete this if needed, except if you want to save your first house with ID 0 as "1.ini".

Also, first checking if HOUSES_FILE exists (whatever that holds), then re-creating the actual path and housefile-name is weird as well.
Reply


Messages In This Thread
New files overwrite eachother - by Devix - 26.07.2012, 11:10
Re: New files overwrite eachother - by Devix - 26.07.2012, 13:02
Re: New files overwrite eachother - by AmigaBlizzard - 26.07.2012, 13:05
Re: New files overwrite eachother - by Devix - 26.07.2012, 13:06
Re: New files overwrite eachother - by AmigaBlizzard - 26.07.2012, 13:21
Re: New files overwrite eachother - by Devix - 26.07.2012, 13:26
Re: New files overwrite eachother - by Devix - 26.07.2012, 18:49
Re: New files overwrite eachother - by AmigaBlizzard - 26.07.2012, 20:45
Re: New files overwrite eachother - by Devix - 26.07.2012, 22:45
Re: New files overwrite eachother - by Devix - 27.07.2012, 12:22

Forum Jump:


Users browsing this thread: 2 Guest(s)