local items =
{
--[numeração] = {id = ID DO ITEM, count = QUANTIDADE DO ITEM, c = CHANCE}
[1]={id=8884, count=1, c=10}, -- item 1
[2]={id=8890, count=1, c=10}, -- item 2
[3]={id=8888, count=1, c=10}, -- item 3
[4]={id=8905, count=1, c=10}, -- item 4
[5]={id=10511, count=1, c=10}, -- item 5
[6]={id=10515, count=1, c=10}, -- item 6
[7]={id=10514, count=1, c=10}, -- item 7
[8]={id=10139, count=1, c=10}, -- item 8
[9]={id=10719, count=1, c=10}, -- item 9
[10]={id=12608, count=75, c=10}, -- item 9
}
function getRandomItem(t)
local i = math.random(1, #t)
i = t[i]
if math.random(1, 100) <= i.c then
return i
end
return getRandomItem(t)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local i = getRandomItem(items)
local effect = 1
local Pos = {x = 1, y = 1, z = 7}
local PlayerPos = {x = getPlayerPosition(cid).x + 0, y = getPlayerPosition(cid).y + 0, z = getPlayerPosition(cid).z}
local stor = 98543
if getPlayerStorageValue(cid,stor) == -1 then
doPlayerAddItem(cid, i.id, i.count)
doTeleportThing(cid, Pos)
doSendMagicEffect(PlayerPos,effect)
doSendAnimatedText(getPlayerPosition(cid), "Magic Box!", TEXTCOLOR_YELLOW)
doPlayerSendTextMessage(cid, 27, "You opened a chest event and won "..i.count.."x "..getItemNameById(i.id)..(i.count > 1 and "s" or "")..".")
doRemoveItem(item.uid, 1)
setPlayerStorageValue(cid,stor,1)
else
doPlayerSendTextMessage(cid,25,"The chest event is empty.")
end
return true
end
Movements
function onStepIn(cid, item, pos)
local stor = x
if getPlayerStorageValue(cid,stor) > 1 then
doPlayerSendCancel(cid,"Removido")
setPlayerStorageValue(cid,stor,0)
end
end