Hello all,
I’m just wrecking my head how to add my generated Items to a database to load it each time the webplayer is used.
I’ve created a simple Item class and several Weapons, Armor, etc that inherit from that Item Class. The Inventory is working well, I store generated Items with random values into my Item-List and show them via GUI Buttons.
The problem here is I can’t think of a way to store them into a database (along with other players) to load them when the player comes back. I thought about auto_increment the database so every added item will have a unique ID, but how can I assign that ID to the Item in Unity to prevent adding the same Item again?
I have a userID, atm 25 Inventoryslots (i think they wont change in future), ItemTypes (Weapon, Torso, etc) and the Itemvalues (price, dmg, several boni stats, etc).
I tried creating an Inventory database with userID, itemType and itemValue to store them and receive them by getting the userID. The problem here is how to select the right item when I want to delete it? Let’s say the player sells the item and I have to remove it from the database, too. How should i select it? I could possibly select it by it’s values, but there could be another item with the exact same values (also if it would be very lucky ^^). So I need a unique value (primary key) to select items from my db, but how to create such a unique value without the danger to insert a duplicate into the db?
I’m no good programmer or database creator ^^ But I really stuck here, can’t figure a way out to correctly store and retrieve or delete the correct items for my Inventory.
Hope you could understand at least a little bit, sry for bad english. Thanks in advance!