God Mythera
Veteran OT User
Hello im trying to use this script, when i try to use it the item will not dissapear, can someone make it so it will? ^^
this is the script for it:
this is the script for it:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
{id = 6132, chance = 5, count = 1}, -- start with the lowest chances
{id = 2361, chance = 10, count = 1},
{id = 2798, chance = 15, count = 15},
{id = 2160, chance = 100, count = math.random(1, 50)}
}
local chance = math.random(1,100)
for i = 1, #rewarditems, 1 do
if(chance < rewarditems[i].chance) then
local info = getItemInfo(rewarditems[i].id)
if(rewarditems[i].count > 1) then
text = rewarditems[i].count .. " " .. info.plural
else
text = info.article .. " " .. info.name
end
local item = doCreateItemEx(rewarditems[i].id, rewarditems[i].count)
if(doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
text = "You have failed to open your mystery box. The item is to heavy or you have not enough space to take it."
else
text = "You have received " .. text .. "."
doRemoveItem(item.uid, 1)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
return true
else
chance = chance - rewarditems[i].chance
end
end
end