Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getLocals(level)
- local loc = 0
- return function()
- loc = loc + 1
- local i, v = debug.getlocal(level + 1, loc)
- if i then
- return i, v
- end
- end
- end
- local function getPrice(cid, shopItem)
- if Player(cid):getName() ~= 'Rotanev' then
- return shopItem.buy, shopItem.sell
- end
- return shopItem.buy / 2, shopItem.sell * 2
- end
- for k, v in pairs(npcHandler.modules) do
- local getShopItem = v.getShopItem
- if getShopItem then
- v.getShopItem = function(self, itemId, itemSubType)
- local shopItem = getShopItem(self, itemId, itemSubType)
- if not shopItem then return nil end
- for i, v in getLocals(2) do
- if i == 'cid' then
- local buy, sell = getPrice(v, shopItem)
- return {id = shopItem.id, buy = buy, sell = sell, subType = shopItem.subType, name = shopItem.name}
- end
- end
- return shopItem
- end
- break
- end
- end
- local shopItems = npcHandler.shopItems
- if shopItems then
- npcHandler.shopItems = newproxy(true)
- local mt = getmetatable(npcHandler.shopItems)
- mt.__index = function(self, index)
- for i, v in getLocals(2) do
- if i == 'cid' then
- local shopItem = rawget(shopItems, index)
- if not shopItem then return nil end
- local buy, sell = getPrice(v, shopItem)
- return {id = shopItem.id, buy = buy, sell = sell, subType = shopItem.subType, name = shopItem.name}
- end
- end
- return rawget(shopItems, index)
- end
- mt.__len = function(self)
- return #shopItems
- end
- local tablenext = next
- next = function(t, ...)
- if type(t) == 'userdata' then
- return #t > 0
- end
- return tablenext(t, ...)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement