local cfg = {
rune = 2268, -- Sudden Death Rune
count = 370, -- Total count of runes to buy
cost = 1000 -- Cost in gold coins
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local count, num = cfg.count, nil
if not player:removeMoney(cfg.cost) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You need '.. cfg.cost - player:getMoney() .. ' more gold.')
return true
end
while count > 0 do
num = math.min(100, count)
player:addItem(cfg.rune, num)
count = count - num
end
player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You have bought %d %s for %d gold coins.', cfg.count, ItemType(cfg.rune):getPluralName(), cfg.cost))
return true
end