Efficient way to design an inventory system?
#7

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
At times like these, one wishes pawn supported classes, it would have made our lives much easier. But hey, a good developer is one who works around problems with what he/she has.
Dignity's method is the most approachable I'd say.
PHP код:
enum ENUM_ITEM
{
e_item_id,
e_item_condition
}
new 
item_info[MAX_ITEMS][ENUM_ITEM]; 
Let's assume an apple which is item ID 46, want to make it infected?
PHP код:
#define ITEM_STATE_INFECTED 1
#define ITEM_STATE_INFECTED 2
item_info[item_id][e_item_condition] = ITEM_STATE_INFECTED
want to store 12 bullets in a shotgun ammo box?
PHP код:
item_info[item_id][e_item_condition] = 12
I believe this method would work just fine, not too much heavy on memory, and to me looks efficient.
Would like to be corrected if I'm mistaken.
Got it!

Still got more questions now; is there a limit to the amount of items used if I use that method? For example, if I use these stats;

- 60 playes playing at the same time, they can carry a maximum of 30 items each
- 20 vehicles in-game, with an average loading capacity of 20 items each
- Roughly 800 dropped items in-game

Would be a total of 3000 items and thus enums. Would this be doable or would it be a big stress on the server?

And how should I link the item to the player?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)