function onUse(cid, item, fromPosition, itemEx, toPosition)
local shop = {
[1016] = {
rune = 2268, container = 2003, cost = 5000, charges = 3, effect = CONST_ME_GIFT_WRAPS
},
[1015] = {
rune = 2269, container = 2002, cost = 3000, charges = 3, effect = CONST_ME_GIFT_WRAPS
}
}
local v = shop[item.actionid]
local weight = getItemWeightById(v.container, getContainerSize(v.container)) + getItemWeightById(v.container, 1)
if(getPlayerFreeCap(cid) >= weight) then
if(getPlayerMoney(cid) >= v.cost) then
local bp = doCreateItemEx(cid, v.container, 1)
doAddContainerItem(bp, v.rune, v.charges)
if(doPlayerAddItemEx(cid, bp, true) ~= RETURNVALUE_NOERROR) then
doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
else
doPlayerRemoveMoney(cid, v.cost)
doSendMagicEffect(getThingPos(cid), v.effect)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased a backpack of " .. getItemNameById(v.rune) .. "'s.")
end
else
doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold.")
end
else
doPlayerSendCancel(cid, "Sorry, you need " .. math.ceil(weight) .. "oz. to carry this item.")
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end