Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local shop = {
- [1000] = {
- rune = 2268, container = 2003, cost = 5000, charges = 100, 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)
- for i = 1, 20 do
- doAddContainerItem(bp, v.rune, v.charges)
- end
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement