local crate = {x=100, y=100, z=7}
local t = {
[2147] = 100, [2153] = 100,
[2146] = 100, [2154] = 100,
[2149] = 100, [2155] = 100,
[2150] = 100, [2156] = 100,
[2145] = 100, [2158] = 100
}
function onUse(cid, item, k, itemEx, toPosition)
k.y = k.y + 1
if doComparePositions(k, getThingPos(cid)) then
local it, money = getTileItemById(crate, 1739).uid, 0
if it == 0 then
return doPlayerSendCancel(cid, 'Sorry, not possible.')
end
for k, v in pairs(t) do
local n = math.min(100, getPlayerItemCount(cid, k))
while n ~= 0 do
doPlayerRemoveItem(cid, k, n)
doAddContainerItem(it, k, n)
money = money + n * v
n = math.min(100, getPlayerItemCount(cid, k))
end
end
if money == 0 then
doCreatureSay(cid, 'You don\'t have any gems.', TALKTYPE_ORANGE_1, false, cid)
else
doPlayerAddMoney(cid, money)
doCreatureSay(cid, 'You sold the gems for ' .. money .. ' gold.', TALKTYPE_ORANGE_1, false, cid)
end
else
doCreatureSay(cid, 'You must stand on the switch tile.', TALKTYPE_ORANGE_1, false, cid)
end
return true
end