Tenta ae:
Primeiro script:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rewarditems = {
{id = 2492, chance = 5, count = 1}, -- start with the lowest chances
{id = 2498, chance = 10, count = 1},
{id = 2488, chance = 15, count = 1},
{id = 2152, chance = 70, count = math.random(1, 10)}
}
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 too heavy or you have not enough space to take it."
else
text = "You have received " .. text .. "."
doRemoveItem(item.itemid, 1)
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
return true
else
chance = chance - rewarditems[i].chance
end
end
end
Segundo:
local stonesMinerar = {
[5709] = {minerioid = 5944, count = math.random(1, 10)}, -- [id da pedra] = {minerioid = id do item que ganha, count = countidade que ganha}
[5624] = {minerioid = 6277, count = math.random(1, 5)},
[8748] = {minerioid = 5880, count = math.random(1, 5)},
[5619] = {minerioid = 12700, count = math.random(1, 3)}
}
local config = {
exhaustionMinutes = 60, -- exausted em minutos
effectChar = 30, -- efeito no char.
storageUse = 34542 -- storage usado/ não mude caso não entenda.
}
local chance = 50
function onUse(cid, item, fromPosition, itemEx, toPosition)
local a = math.random(1, 100)
if(exhaustion.check(cid, config.storageUse) == TRUE) then
if (exhaustion.get(cid, config.storageUse) >= 60) then
doPlayerSendCancel(cid, "Voçê só pode usar após [" .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .."] minutos.")
end
if (exhaustion.get(cid, config.storageUse) <= 60) then
doPlayerSendCancel(cid, "Voçê só pode usar após [" .. exhaustion.get(cid, config.storageUse).."] segundos.")
end
return true
end
if stonesMinerar[itemEx.itemid] then
if a < chance then
doPlayerAddItem(cid, stonesMinerar[itemEx.itemid].minerioid, stonesMinerar[itemEx.itemid].count)
doPlayerSendTextMessage(cid, 19, "Você recebeu "..(stonesMinerar[itemEx.itemid].count).." "..getItemNameById(stonesMinerar[itemEx.itemid].minerioid).."!")
doSendMagicEffect(getPlayerPosition(cid), config.effectChar)
exhaustion.set(cid, config.storageUse, config.exhaustionMinutes*60)
else
doPlayerSendCancel(cid, "Você falhou.")
end
else
doPlayerSendCancel(cid, "Você não pode minerar isso.")
end
return true
end





info
Grupo: Visconde
Registrado: 26/08/10
Posts: 431
Reputação: +60
Gênero: Masculino
Char no Tibia: Gabriel Rookgaardian
Estou com esses dois scripts que não estou conseguindo ajeitar. Segue eles:
O problema desse é que não remove de jeito nenhum o item quando ele é usado:
function onUse(cid, item, fromPosition, itemEx, toPosition) local rewarditems = { {id = 2492, chance = 5, count = 1}, -- start with the lowest chances {id = 2498, chance = 10, count = 1}, {id = 2488, chance = 15, count = 1}, {id = 2152, chance = 70, count = math.random(1, 10)} } 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 endEsse eu não estou conseguindo por uma chance individual para cada item e nem estou conseguindo por um math.randon pra vir uma quantidade aleatória dos itens.
local stonesMinerar = { [5709] = {minerioid = 5944, count = math.random(1, 10)}, -- [id da pedra] = {minerioid = id do item que ganha, count = countidade que ganha} [5624] = {minerioid = 6277, count = math.random(1, 5)}, [8748] = {minerioid = 5880, count = math.random(1, 5)}, [5619] = {minerioid = 12700, count = math.random(1, 3)} } local config = { exhaustionMinutes = 60, -- exausted em minutos effectChar = 30, -- efeito no char. storageUse = 34542 -- storage usado/ não mude caso não entenda. } local chance = 50 function onUse(cid, item, fromPosition, itemEx, toPosition) local a = math.random if(exhaustion.check(cid, config.storageUse) == TRUE) then if (exhaustion.get(cid, config.storageUse) >= 60) then doPlayerSendCancel(cid, "Voçê só pode usar após [" .. math.floor(exhaustion.get(cid, config.storageUse) / 60 + 1) .."] minutos.") end if (exhaustion.get(cid, config.storageUse) <= 60) then doPlayerSendCancel(cid, "Voçê só pode usar após [" .. exhaustion.get(cid, config.storageUse).."] segundos.") end return true end if stonesMinerar[itemEx.itemid] then local a = math.random(1, 100) if a < chance then doPlayerAddItem(cid, stonesMinerar[itemEx.itemid].minerioid, stonesMinerar[itemEx.itemid].count) doPlayerSendTextMessage(cid, 19, "Você recebeu "..(stonesMinerar[itemEx.itemid].count).." "..getItemNameById(stonesMinerar[itemEx.itemid].minerioid).."!") doSendMagicEffect(getPlayerPosition(cid), config.effectChar) exhaustion.set(cid, config.storageUse, config.exhaustionMinutes*60) else doPlayerSendCancel(cid, "Você falhou.") end else doPlayerSendCancel(cid, "Você não pode minerar isso.") end return true endSe alguém puder ajudar, agradeço desde já.