Quote:
Originally Posted by BroZeus
use separate Tags for each property using INI_SetTag() function
|
Thanks, I didn't know you could use settag like that, didn't really understand what it was for to be honest. It 50% worked, although I have a property limit of 899, and it only saved from 456, not 1. Here's the code I got:
pawn Код:
stock SaveHouses()
{
new pathstring[126], tagstring[4];
format(pathstring, sizeof(pathstring), "houses.ini");
new INI:File = INI_Open(pathstring);
for(new i = 1; i < sizeof(HouseData); i++)
{
format(tagstring, sizeof(tagstring), "%d", i);
INI_SetTag(File, tagstring);
INI_WriteInt(File, "Created", HouseData[i][Created]);
INI_WriteString(File, "Owner", HouseData[i][Owner]);
INI_WriteInt(File, "Locked", HouseData[i][Locked]);
INI_WriteInt(File, "ForSale", HouseData[i][ForSale]);
INI_WriteInt(File, "Owned", HouseData[i][Owned]);
INI_WriteInt(File, "ForSaleSign", HouseData[i][ForSaleSign]);
INI_WriteInt(File, "SalePrice", HouseData[i][SalePrice]);
INI_WriteInt(File, "ForRent", HouseData[i][ForRent]);
INI_WriteInt(File, "RentPrice", HouseData[i][RentPrice]);
INI_WriteFloat(File, "EntranceA", HouseData[i][Entrance][0]);
INI_WriteFloat(File, "EntranceX", HouseData[i][Entrance][1]);
INI_WriteFloat(File, "EntranceY", HouseData[i][Entrance][2]);
INI_WriteFloat(File, "EntranceZ", HouseData[i][Entrance][3]);
INI_WriteFloat(File, "ExitA", HouseData[i][Exit][0]);
INI_WriteFloat(File, "ExitX", HouseData[i][Exit][1]);
INI_WriteFloat(File, "ExitY", HouseData[i][Exit][2]);
INI_WriteFloat(File, "ExitZ", HouseData[i][Exit][3]);
INI_WriteString(File, "Address", HouseData[i][Address]);
INI_WriteFloat(File, "SaleSignA", HouseData[i][ForSaleSignPos][0]);
INI_WriteFloat(File, "SaleSignX", HouseData[i][ForSaleSignPos][1]);
INI_WriteFloat(File, "SaleSignY", HouseData[i][ForSaleSignPos][2]);
INI_WriteFloat(File, "SaleSignZ", HouseData[i][ForSaleSignPos][3]);
INI_WriteInt(File, "Interior", HouseData[i][Interior]);
if(HouseData[i][ForSaleSign]) DestroyDynamicObject(HouseData[i][ForSaleSign]);
}
INI_Close(File);
print("SaveHouses finished");
return 1;
}
Also, how would I go about making a likewise load function where it has multiple tags?
Like I know how to load a file with the tag variable, but how would I make the tag loop like I have with the save function?
So you have:
pawn Код:
INI:other[// tag name goes here but i'd need to loop through HouseData](name[], value[])
{
}