function onUse(cid, item, fromPosition, itemEx, toPosition)
local shop = {
[1000] = {
id = 2268, container = 2003, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1001] = {
id = 2273, container = 2002, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1002] = {
id = 2304, container = 2000, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1003] = {
id = 2313, container = 2001, cost = 50000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1004] = {
id = 2280, container = 1995, cost = 30000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1005] = {
id = 2173, container = 1994, cost = 80000, effect = CONST_ME_GIFT_WRAPS
},
[1006] = {
id = 2268, container = 2003, cost = 100000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1007] = {
id = 2273, container = 2002, cost = 100000,charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1014] = {
id = 2173, container = 1994, cost = 80000, effect = CONST_ME_GIFT_WRAPS
},
[1009] = {
id = 2280, container = 1995, cost = 100000, effect = CONST_ME_GIFT_WRAPS
},
[1010] = {
id = 7850, container = 3940, cost = 100000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1011] = {
id = 7838, container = 3940, cost = 100000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1012] = {
id = 7839, container = 3940, cost = 100000, charges = 100, effect = CONST_ME_GIFT_WRAPS
},
[1013] = {
id = 7363, container = 3940, cost = 100000, charges = 100, effect = CONST_ME_GIFT_WRAPS
}
}
local v = shop[item.actionid]
local weight = getItemWeightById(v.id, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
if(getPlayerFreeCap(cid) >= weight) then
if(getPlayerMoney(cid) >= v.cost) then
local bp = doCreateItemEx(cid, v.container, 1)
if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
else
for i = 1, tonumber(getItemInfo(v.container).maxItems) do
doAddContainerItem(bp, v.id, v.charges or 1)
end
doPlayerRemoveMoney(cid, v.cost)
doSendMagicEffect(getThingPos(cid), v.effect)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have purchased a backpack of " .. getItemInfo(v.id).plural .. ".")
end
else
doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold.")
end
else
doPlayerSendCancel(cid, "Sorry, you need " .. weight:format("%.2f") .. " oz. to carry this container of " .. getItemInfo(v.id).plural .. ".")
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end