Hello, someone could help me with a script when i click a bag give a random reward (example: 50% chance obtain "x" item, 25% another item) and i need a key to open the bag (if i open the bag both key and bag dissapear and i obtain reward to my backpack)
I'm using this script but i don't need key to open it and give me only 1 reward item:
Sorry my bad english and thanks
I'm using this script but i don't need key to open it and give me only 1 reward item:
LUA:
local prize = {
[1] = {chance = 25, id = 5897, amount = 1,5},
[2] = {chance = 30, id = 5896, amount = 1,5},
[3] = {chance = 40, id = 5909, amount = 1,5},
[4] = {chance = 55, id = 5913, amount = 1,5},
[5] = {chance = 100, id = 5914, amount = 2,5},
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
for i = 1,#prize do local number = math.random() * 100
if prize[i].chance>100-number then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:addItem(prize[i].id, prize[i].amount)
item:remove()
break
end
end
return true
end
Sorry my bad english and thanks