26.07.2012, 13:21
Try this instead:
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.
Код:
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; }
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.