New files overwrite eachother
#8

You might wanna get rid of the "houseid++".

Let's say you want to save house with ID 0.
Adding 1 to the houseid would mean you're gonna save the data in the file 1.ini, instead of 0.ini.
It also means you're gonna save the data stored for houseid 1 into the datafile for houseid 0.
But the data for houseid 1 in your array isn't set yet.
That's why you always get empty strings, and integer/float values of 0.

Also, assume you only have 10 houses, with id 0 to 9.
Using the houseid++ in the save-function to save houseid 9 would mean you're gonna create a file called 10.ini.
You would also save the data stored at index 10 of your array, which doesn't exist as the array only has index 0 to 9.

Just get rid of the houseid++ and it will work properly.

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

	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;
}
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: 1 Guest(s)