Efficient way to design an inventory system?
#4

I added "params" to the items in my inventory system.

An item could have up to three params, and I used a threading method for item related functions (OnPlayerUseItem, OnPlayerItemPickup, ... ) which put them into motion. i.e. the containments of the item "Bottle" were determined by the first param, being Whiskey, Vodka, etc. and the second param declared how full the bottle was (0=full, 1=half, 2=empty) and so on.

You should also create a seperate table for items. Keeps your 'players' table organised and contained. Item data is an entirely different thing so they shouldn't interwine with player stuff. Here's how I did it:



player_table_id is stored in the enumerator so I could easily remove entries from the items table. player_database_id is the player who owns the item. player_item_id is the item in question. amount, param1 and param2 should be self explanatory.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)