[Question] Saving Items

08/09/2009 17:18 Kital82#1
Hello.
I'm using my source with .ini files
I would like to know what is the best between
Saving all items in only 1 folder where all items are into
Exemple of a item file:
Quote:
OwnerID=10000001
Location=0
ItemUID=123456789
ItemID=410339
Plus=12
Bless=7
Enchant=255
Soc1=13
Soc2=13
Dura=40
MaxDura=40
or making a folder for Inventory, Equipements, Whs ... wich define item UID when loading ...
Exemple of a Character's Inventory file:
Quote:
[Inventory]
Count=2
0=410339 12 7 255 13 13
1=480339 12 7 255 13 13
So what could be the best solution?
"I know that using MySql is faster, but I'm making with IniFile atm"
08/09/2009 17:31 tanelipe#2
I'd probably go for this if I was using Inis. I'd be using the account to identifier which inventory file belongs to whom. So something like I've demonstrated below.

Code:
[Inventory]
Count=2
Item0=410339 12 7 255 13 13
Item1=480339 12 7 255 13 13

Code:
IniFile File = new IniFile(DatabasePath + "\\Inventories\\" + Client.Username + ".ini");
sbyte Count = File.ReadSByte("Inventory", "Count", -1);
if(Count == -1) { 
	// Whatever happens if there is no inventory yet, or for some reason it isn't possible to read the data.
}
for(sbyte i = 0; i < Count; i++) {
	ItemStructure Item = ItemStructure.Parse(File.ReadString("Inventory", "Item" + i, "0 0 0 0 0 0"));
	Client.Entity.Inventory.AddItem(Item);

}
Sorry about the length, got a little bit carried away, lol.