local items = {
[11350] = 10000,
[2181] = 5000,
[11296] = 50000,
[11298] = 14000,
[8885] = 100000,
[2519] = 8000,
[2392] = 4000,
[8910] = 12000,
[8871] = 8000,
[2393] = 20000,
[11295] = 10000,
[11299] = 10000,
[2528] = 10000,
[2195] = 40000,
[2516] = 4000,
[2498] = 40000,
[2492] = 45000,
[2656] = 12000,
[2514] = 60000,
[2472] = 150000,
[2520] = 50000,
[2470] = 50000,
[2503] = 50000,
[7897] = 11000,
[2466] = 20000,
[8873] = 3000,
[3968] = 1000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local x = items[itemEx.itemid]
if x then
doRemoveItem(itemEx.uid, 1)
doPlayerAddMoney(cid, x)
local info = getItemInfo(itemEx.itemid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold "..info.article.." "..info.name.." for "..x.." gold.")
doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
elseif isContainer(itemEx.uid) then
local m, size, t = 0, getContainerSize(itemEx.uid), {}
if size == 0 then
return doPlayerSendCancel(cid, "This container is empty.")
end
for s = 0, size do
local citem = getContainerItem(itemEx.uid, s)
local cx = items[citem.itemid]
if cx then
table.insert(t, citem)
end
end
for r = 1, #t do
doRemoveItem(t[r].uid, 1)
m = m + items[t[r].itemid]
end
if m > 0 then
doPlayerAddMoney(cid, m)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You sold your items for "..m.." gold.")
doSendMagicEffect(getThingPos(cid), CONST_ME_FIREWORK_YELLOW)
else
doPlayerSendCancel(cid, "There is nothing in this container that is sellable.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You can't sell this item.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
return true
end