sick
Member
Hello,
So i've came across an issue:
Idea is to click on a gift box and receive items on random basis, get not just one item but any of listed ones. Currently it rewards you with only 1 item. Please help out with this one:
REP+ for assistance!
So i've came across an issue:
Idea is to click on a gift box and receive items on random basis, get not just one item but any of listed ones. Currently it rewards you with only 1 item. Please help out with this one:
Lua:
local items = {
[0] = {id = 10129, count = 1, chance = 2},
[1] = {id = 10128, count = 1, chance = 5},
[2] = {id = 2328, count = 1, chance = 10},
[3] = {id = 2195, count = 1, chance = 15},
[4] = {id = 2160, count = 10, chance = 30},
[5] = {id = 6569, count = 10, chance = 100}
}
function onUse(cid, item, fromPos, itemEx, toPos)
for i = 0, #items do
if (items[i].chance > math.random(1, 100)) then
doPlayerSetMaxCapacity(cid, getPlayerFreeCap(cid) + 100)
doPlayerAddItem(cid, items[i].id, items[i].count)
doRemoveItem(item.uid, 1)
return doCreatureSay(cid, 'I congratulate you won item! This item is '..getItemNameById(items[i].id)..'!', TALKTYPE_MONSTER)
end
end
doRemoveItem(item.uid, 1)
return doCreatureSay(cid, 'Sorry, have not won anything!', TALKTYPE_MONSTER)
end
REP+ for assistance!