Deleting Item from Inventory
Posted: Mon Aug 31, 2015 11:09 pm
Need help in figuring out how to delete an item from inventory. Looking at the charutils.cpp, how do I modify the addItem (into delItem) so that the same parameters still apply and will remove an item with specified quantity? Appreciate the response!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uint8 AddItem(CCharEntity* PChar, uint8 LocationID, uint16 ItemID, uint32 quantity, bool silence)
{
if (PChar->getStorage(LocationID)->GetFreeSlotsCount() == 0 || quantity == 0)
{
return ERROR_SLOTID;
}
CItem* PItem = itemutils::GetItem(ItemID);
if (PItem != nullptr)
{
PItem->setQuantity(quantity);
return AddItem(PChar, LocationID, PItem, silence);
}
ShowWarning(CL_YELLOW"charplugin::AddItem: Item <%i> is not found in a database\n" CL_RESET, ItemID);
return ERROR_SLOTID;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uint8 AddItem(CCharEntity* PChar, uint8 LocationID, uint16 ItemID, uint32 quantity, bool silence)
{
if (PChar->getStorage(LocationID)->GetFreeSlotsCount() == 0 || quantity == 0)
{
return ERROR_SLOTID;
}
CItem* PItem = itemutils::GetItem(ItemID);
if (PItem != nullptr)
{
PItem->setQuantity(quantity);
return AddItem(PChar, LocationID, PItem, silence);
}
ShowWarning(CL_YELLOW"charplugin::AddItem: Item <%i> is not found in a database\n" CL_RESET, ItemID);
return ERROR_SLOTID;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~