17.10.2017, 16:35
Quote:
|
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? |
e.g. if youre using pickups for those dropped items
Код:
enum ENUM_ITEM
{
e_item_id,
e_item_condition,
e_item_pickup_id
}
Using this plugin handling a players inventory would come down to just this
Код:
// On server start for each player slot, vehicle, etc gPlayer[playerid][item_id_vector] = cvector(); gPlayer[playerid][item_condition_vector] = cvector(); // Getting an item itemid = cvector_get(gPlayer[playerid][item_id_vector], item_slot); itemCondition = cvector_get(gPlayer[playerid][item_condition_vector], item_slot); // Adding an item cvector_push_back(gPlayer[playerid][item_id_vector], item_id); cvector_push_back(gPlayer[playerid][item_condition_vector], item_condition); // Removing an item cvector_remove(gPlayer[playerid][item_id_vector], item_slot); cvector_remove(gPlayer[playerid][item_condition_vector], item_slot); // On player leave // Save items to database, then clear the vector so the next player wont "inherit" the items in that player slot cvector_clear(gPlayer[playerid][item_id_vector]); cvector_clear(gPlayer[playerid][item_condition_vector]);
Fixed-size arrays just are a bad choice when the range of inventory sizes is rather big.
My complete multilayer inventory engine, including save/load, isnt even 400 lines.


