local shop = {
[1000] = {
rune = 2268, cost = 5000, charges = 3, effect = CONST_ME_GIFT_WRAPS
},
[1001] = {
rune = 2273, cost = 3000, charges = 3, effect = CONST_ME_GIFT_WRAPS
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = shop[item.actionid]
if getPlayerMoney(cid) < v.cost then
doPlayerSendCancel(cid, "You need " .. v.cost .. " gold to buy this item.")
elseif getPlayerFreeCap(cid) < getItemInfo(v.rune).weight then
doPlayerSendCancel(cid, "You need " .. string.format("%.2f", getItemInfo(v.rune).weight) .. " oz. to take this item.")
else
local k = doCreateItemEx(v.rune, v.charges)
if doPlayerAddItemEx(cid, k) ~= RETURNVALUE_NOERROR then
doPlayerSendCancel(cid, "You don't have enough space.")
else
doPlayerRemoveMoney(cid, v.cost)
doSendMagicEffect(getThingPos(cid), v.effect)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased a backpack of " .. getItemInfo(v.rune).plural .. ".")
doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
end
return true
end