Teste assim:
local storage = 1445 -- storage utilizada
local premio = 2688 -- item que o player vai ganhar
local msg = "Você achou um item!"
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, storage) >= 0 then
return doPlayerSendCancel(cid, "O baú está vazio.")
end
if getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid > 0 then
return doPlayerSendCancel(cid, "Tire o item que está no slot de munição.")
end
local addedItems, playerWeight = {}, getPlayerFreeCap(cid)
for slot = 1, 10 do
local i = getPlayerSlotItem(cid, slot)
if i.uid > 0 then playerWeight = playerWeight + getItemWeight(i.uid) end
end
local a = doPlayerAddItem(cid, premio, 1, false)
table.insert(addedItems, a)
if not addedItems[1] then
return doPlayerSendCancel(cid, "Você não tem capacidade para carregar o item!")
end
if getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid == addedItems[1] then
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, 22, msg)
return true
end
doPlayerSetMaxCapacity(cid, 999999)
for tries = 2, 10 do
local a = doPlayerAddItem(cid, premio, 1, false)
table.insert(addedItems, a)
if getPlayerSlotItem(cid, CONST_SLOT_AMMO).uid == addedItems[tries] then
setPlayerStorageValue(cid, storage, 1)
doPlayerSendTextMessage(cid, 22, msg)
doPlayerSetMaxCapacity(cid, playerWeight)
for _, removeId in pairs (addedItems) do
if _ ~= tries then doRemoveItem(removeId) end
end
return true
end
end
for _, removeId in pairs (addedItems) do
if _ ~= tries then doRemoveItem(removeId) end
end
return true
end





info
Grupo: Campones
Registrado: 15/06/12
Posts: 57
Reputação: +1
Char no Tibia: Virus
aew galera, queria um sistema que fosse assim:
eu fasso uma quest ai ganho um item e ele vai direto pra ca
tem como fazer isso?
obs o item eu botei imobili não tem problema ne?