Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _ODIRION_RUNES_STTGS = {
- runeids = {2287, 2288},
- }
- function onPlayerBuyingMarket(cid, itembp, itemid, amount, town)
- runelist = _ODIRION_RUNES_STTGS.runeids
- local default_backpack = 2004
- if isNumber(itembp) then default_backpack = tonumber(itembp) end
- local name = getPlayerName(cid)
- if isItemStackable(itemid) and not isInArray(runelist, itemid) then
- am, vl = 0, 0
- bps = getMarketBpAmount(cid, amount, 100)
- if bps < 1 then bps = 1 end
- for g = 1, bps do
- local j = doCreateItemEx(default_backpack-1)
- for a = 1, 20 do
- if (am+100) > amount then vl = (amount - am) else vl = 100 end
- if am < amount then
- doAddContainerItem(j, itemid, vl)
- am = am + vl
- else
- break
- end
- end
- doPlayerSendMailByName(name, j, town, "")
- end
- elseif isInArray(runelist, itemid) then
- local j = doCreateItemEx(default_backpack-1)
- for a = 1, 20 do
- doAddContainerItem(j, itemid, amount)
- end
- doPlayerSendMailByName(name, j, town, "")
- else
- local j = doCreateItemEx(itemid-1)
- doPlayerSendMailByName(name, j, town, "")
- end
- return true
- end
- function getMarketBpAmount(cid, value, count)
- ctrl, result = value, 0
- while value >= count do
- result = result + 1
- value = value - count
- end
- result = math.ceil(result / 20)
- if value >= 1 and ctrl > 2000 then result = result + 1 end
- return result
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement