Svira
Active Member
- Joined
- Jan 27, 2008
- Messages
- 267
- Solutions
- 11
- Reaction score
- 36
Hello,
I have the following script which is responsible for selling items after use:
the problem is that if we sell an item in a monster's body, we will receive money and the item will remain in a corpse.
QUESTION:
What should the exception look like that allows you to sell items only from the player's backpack?
I have the following script which is responsible for selling items after use:
Lua:
local items = {
[XXXx] = 21500, -- [ItemID] = PriceOfItem
}
function onUse(player, item, fromPosition, itemEx, target, toPosition, isHotkey)
local tmpItem = items[itemEx.itemid]
if not tmpItem then
player:sendCancelMessage("You can't sell this item.")
return true
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have sold your item!')
player:removeItem(itemEx.itemid, 1)
player:addMoney(tmpItem)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
return true
end
the problem is that if we sell an item in a monster's body, we will receive money and the item will remain in a corpse.
QUESTION:
What should the exception look like that allows you to sell items only from the player's backpack?