Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. _ODIRION_RUNES_STTGS = {
  2.     runeids = {2287, 2288},
  3. }
  4.  
  5. function onPlayerBuyingMarket(cid, itembp, itemid, amount, town)
  6.     runelist = _ODIRION_RUNES_STTGS.runeids
  7.     local default_backpack = 2004
  8.     if isNumber(itembp) then default_backpack = tonumber(itembp) end
  9.     local name = getPlayerName(cid)
  10.     if isItemStackable(itemid) and not isInArray(runelist, itemid) then
  11.         am, vl = 0, 0
  12.         bps = getMarketBpAmount(cid, amount, 100)
  13.         if bps < 1 then bps = 1 end
  14.         for g = 1, bps do
  15.             local j = doCreateItemEx(default_backpack-1)
  16.             for a = 1, 20 do
  17.                 if (am+100) > amount then vl = (amount - am) else vl = 100 end
  18.                 if am < amount then
  19.                     doAddContainerItem(j, itemid, vl)
  20.                     am = am + vl
  21.                 else
  22.                     break
  23.                 end
  24.             end
  25.             doPlayerSendMailByName(name, j, town, "")
  26.         end
  27.     elseif isInArray(runelist, itemid) then
  28.         local j = doCreateItemEx(default_backpack-1)
  29.         for a = 1, 20 do
  30.             doAddContainerItem(j, itemid, amount)
  31.         end
  32.         doPlayerSendMailByName(name, j, town, "")
  33.     else
  34.         local j = doCreateItemEx(itemid-1)
  35.         doPlayerSendMailByName(name, j, town, "")
  36.     end
  37. return true
  38. end
  39.  
  40. function getMarketBpAmount(cid, value, count)
  41.     ctrl, result = value, 0
  42.     while value >= count do
  43.         result = result + 1
  44.         value = value - count
  45.     end
  46.     result = math.ceil(result / 20)
  47.     if value >= 1 and ctrl > 2000 then result = result + 1 end
  48. return result
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement