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;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deleting Item from Inventory
Re: Deleting Item from Inventory
You delete items by using UpdateItem to set its quantity to 0
-
- Posts: 4
- Joined: Thu Jul 30, 2015 7:53 am
Re: Deleting Item from Inventory
Sorry another noob question. How do I call the UpdateItem function in a lua script?
Re: Deleting Item from Inventory
what do you need it for? I think every time an item is deleted via script would be done by trade
Re: Deleting Item from Inventory
!
Last edited by tabitaru on Sun Oct 18, 2015 7:01 am, edited 1 time in total.
-
- Posts: 4
- Joined: Thu Jul 30, 2015 7:53 am
Re: Deleting Item from Inventory
Scenario: A GM was giving items away and accidentally gave one to an incorrect person. Just want to remove the item using the same syntax as giveitem <player> <itemID> <quantity> - assuming the location is in the inventory bag.
Re: Deleting Item from Inventory
How do you know that person didn't trade off the item already, or move it to a storage location? Might have to go into the dbsonicblazer wrote:Scenario: A GM was giving items away and accidentally gave one to an incorrect person. Just want to remove the item using the same syntax as giveitem <player> <itemID> <quantity> - assuming the location is in the inventory bag.
-- Whasf
Re: Deleting Item from Inventory
oh.. I'd just log them out and then delete the entry from the db table. It's very annoying to do something like that because you don't know the slot id. While you can just say "delete the first item of this ID that I find", there's no guarantee that it's the actual one you added. you'll have to write the lua binding yourself if you want to do that - iterate over the inventory and remove the first item matching the id