03-30-2021, 10:12 AM
Ofc make sure to check if inventory space is enought before call it.
if(pc->m_inventory.getEmptyCount() < n) /* where n is the number of the items that you are gonna add */
{
CNetMsg::SP rmsg(new CNetMsg);
SysFullInventoryMsg(rmsg, 0);
SEND_Q(rmsg, pc->m_desc);
return false;
}
NB: that function will not check stackable items, you can always recode the function getEmptyCount where the function will get the number of the items that you are trying to create and check in the "pc inventory" if there are other stackable items in the inventory.
You can easy check for items in the inventory with that function:
//that should work ONLY with stackable items instead ...
if (pc->m_inventory.FindByDBIndex(x) != NULL)
{
bool MakeItems(CPC* pc, CItem* pItem)
}
else if(pc->m_inventory.getEmptyCount() < n) /* where n is the number of the items that you are gonna add */
{
CNetMsg::SP rmsg(new CNetMsg);
SysFullInventoryMsg(rmsg, 0);
SEND_Q(rmsg, pc->m_desc);
return false;
{
else
{
bool MakeItems(CPC* pc, CItem* pItem)
}
pretty [CeNsOrEd] code i know, but that's whould works
With that you should allow the players to gain the rewards even if the inventory is full, by allowing the function "additems" to perform the addition even if the pc have the inventory full.

