Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. function onUse(cid, item, fromPosition, itemEx, toPosition)
  2.     local shop = {
  3.         [1000] = {
  4.             rune = 2268, container = 2003, cost = 5000, charges = 100, effect = CONST_ME_GIFT_WRAPS
  5.         },
  6.         [1015] = {
  7.             rune = 2269, container = 2002, cost = 3000, charges = 3, effect = CONST_ME_GIFT_WRAPS
  8.         }
  9.     }
  10.     local v = shop[item.actionid]
  11.     local weight = getItemWeightById(v.container, getContainerSize(v.container)) + getItemWeightById(v.container, 1)                  
  12.     if(getPlayerFreeCap(cid) >= weight) then
  13.         if(getPlayerMoney(cid) >= v.cost) then
  14.             local bp = doCreateItemEx(cid, v.container, 1)
  15.             for i = 1, 20 do
  16.                 doAddContainerItem(bp, v.rune, v.charges)
  17.             end
  18.             if(doPlayerAddItemEx(cid, bp, true) ~= RETURNVALUE_NOERROR) then
  19.                 doPlayerSendCancel(cid, "Sorry, you do not have enough space.")
  20.             else
  21.                 doPlayerRemoveMoney(cid, v.cost)
  22.                 doSendMagicEffect(getThingPos(cid), v.effect)
  23.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased a backpack of " .. getItemNameById(v.rune) .. "'s.")
  24.             end
  25.         else
  26.             doPlayerSendCancel(cid, "Sorry, you must have " .. v.cost .. " gold.")
  27.         end
  28.     else
  29.         doPlayerSendCancel(cid, "Sorry, you need " .. math.ceil(weight) .. "oz. to carry this item.")
  30.     end
  31.     return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement