16.10.2017, 21:40
I am currently working on a gamemode to try new things, one of the things I want to learn is to design an inventory system.
Basically the design that I wrote down on a piece of paper is as follows: the gamemode contains several types items (+/- 100). A player can have a set amount of items in his inventory, depending on if he carries a backpack. This ranges between 5 items (no backpack) and 30 items (largest backpack).
Vehicles can also store items, depending on the size of the vehicle. Ranging between 0 items for bikes to 200 items for large trucks.
Items can also be dropped on the ground, then it'll stay there until someone picks it up, with a maximum of 30 minutes.
Items of one specific type can be in certain conditions. For example:
- A pack of bullets can contain 1 or 15 bullets
- A jerrycan can contain water, gas or nothing
- A key has a unique value to correspond to one specific lock
Every item and every condition has a unique number. For example: a pack of 9mm bullets has ID 35. The condition will be stored in a second integer, for example 15 (bullets).
I am using MySQL to store information.
What would be the most efficient way to save information about inventories and items, both in the SQL database and in-game?
Would it be the best to have +/- 30 columns for items, +/- 30 columns for item conditions in the 'players' table in SQL and then store it in the players enum array in the script?
Would it be better to have a seperate table to list every item owner by every player? And how would I then store this in the script? A seperate enum array?
I lack the technical knowledge to explain this as good as I wish, I hope someone out here has experience with this and can help me around because this is the part that I am stuck on now.
Basically the design that I wrote down on a piece of paper is as follows: the gamemode contains several types items (+/- 100). A player can have a set amount of items in his inventory, depending on if he carries a backpack. This ranges between 5 items (no backpack) and 30 items (largest backpack).
Vehicles can also store items, depending on the size of the vehicle. Ranging between 0 items for bikes to 200 items for large trucks.
Items can also be dropped on the ground, then it'll stay there until someone picks it up, with a maximum of 30 minutes.
Items of one specific type can be in certain conditions. For example:
- A pack of bullets can contain 1 or 15 bullets
- A jerrycan can contain water, gas or nothing
- A key has a unique value to correspond to one specific lock
Every item and every condition has a unique number. For example: a pack of 9mm bullets has ID 35. The condition will be stored in a second integer, for example 15 (bullets).
I am using MySQL to store information.
What would be the most efficient way to save information about inventories and items, both in the SQL database and in-game?
Would it be the best to have +/- 30 columns for items, +/- 30 columns for item conditions in the 'players' table in SQL and then store it in the players enum array in the script?
Would it be better to have a seperate table to list every item owner by every player? And how would I then store this in the script? A seperate enum array?
I lack the technical knowledge to explain this as good as I wish, I hope someone out here has experience with this and can help me around because this is the part that I am stuck on now.