local easy = { 7618, 7620, 2389 }
local rare = { 7588, 7589, 2268 }
local veryRare = { 7367 }
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.actionid ~= 10001 then
return false
end
target:remove()
toPosition:sendMagicEffect(CONST_ME_POFF)
local random = math.random(1, 100)
if ((random > 0) and (random <= 50)) then
player:addItem(easy[math.random(#easy)], 1)
elseif ((random > 50) and (random <= 85)) then
player:addItem(rare[math.random(#rare)], 1)
else
player:addItem(veryRare[math.random(#veryRare)], 1)
end
return true
end
Segue uma segunda versão:
local itens = { 7618, 7620, 2389, 7588, 7589, 2268, 7367 }
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.actionid ~= 10001 then
return false
end
if math.random(1, 100) <= 20 then player:addItem(itens[math.random(#itens)], 1) end
target:remove()
toPosition:sendMagicEffect(CONST_ME_POFF)
return true
end