local quest = {
[12200] = {name = "Salve o mundo", done = 1},
[12201] = {name = "A volta dos que nao foram", done = 1},
[12202] = {name = "Eu, eu mesmo e Irene", done = 1},
[12203] = {name = "Todo Poderoso", done = 1},
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local t = {}
for i = 0, getPlayerInstantSpellCount(cid) - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if(spell.level ~= 0) then
if(spell.manapercent > 0) then
spell.mana = spell.manapercent .. "%"
end
table.insert(t, spell)
end
end
local tabela = {}
for a, b in pairs(quest) do
if getPlayerStorageValue(cid, a) == b.done then
table.insert(tabela, ""..b.name.."\n")
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local text, prevLevel = "", -1
for i, spell in ipairs(t) do
local line = ""
if(prevLevel ~= spell.level) then
if(i ~= 1) then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
if #tabela > 0 then
local info = 'Nome : '..getCreatureName(cid)..' \nLevel : '..getPlayerLevel(cid)..' \nHealth : ['..getCreatureHealth(cid)..'/'..getCreatureMaxHealth(cid)..'] \nMana: ['..getCreatureMana(cid)..'/'..getCreatureMaxMana(cid)..'] \n \n'
doShowTextDialog(cid, item.itemid,''..info..'Quests completadas:\n\n'..table.concat (tabela)..'\n'..text..'')
else
doShowTextDialog(cid, item.itemid,''..info..'Nenhuma quest completada.'..text..'')
end
if(fromPosition.x ~= CONTAINER_POSITION) then
doSendMagicEffect(fromPosition, CONST_ME_HITBYFIRE)
end
return true
end