• 0

    posted a message on Detecting when a player manually sells or destroys an item?
    As the title implies, I'm trying to detect if a player has manually sold or destroyed an item.

    There don't really seem to be any events that are indicative of this happening, at least none I can tell.

    I did a trace of selling an item and it looks something like this:

    ITEM_LOCK_CHANGED (bagID = 0, slot = 2)
    ITEM_LOCKED (bagID = 0, slot = 2)
    BAG_UPDATE (containerID = 0)
    PLAYER_MONEY
    MERCHANT_UPDATE
    BAG_UPDATE_DELAYED

    which doesn't exactly seem very useful.

    I could perhaps listen for MERCHANT_UPDATE and check the merchant's buy-back tab (how?) to see if an item was added to the list, but I'm not sure how much of a reliable/smart idea that is - and plus it doesn't work for deleting items at all.

    For deleting an item, it looks like this:

    DELETE_ITEM_CONFIRM (Item name = Blacksmith Hammer, 1, 0, 0)
    ITEM_LOCK_CHANGED (bagID = 0, slot = 4)
    ITEM_UNLOCKED (bagID = 0, slot = 4)
    BAG_UPDATE (container ID = 0)
    BAG_UPDATE_DELAYED

    I could try remembering the item names off any DELETE_ITEM_CONFIRM prompts, followed by looking at BAG_UPDATE to see if that item was actually removed - but it also seems rather brittle and inelegant.

    Does anybody have any ideas as for how I could do this in a clean and elegant way?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.