function onSay(cid, words, param, channel) local maxSpellsToShow = 5000 -- Define o número máximo de feitiços a serem mostrados local t = {} -- Loop através dos feitiços do jogador for i = 0, getPlayerInstantSpellCount(cid) - 1 do if #t >= maxSpellsToShow then break -- Sai do loop se o limite máximo de feitiços for atingido end local spell = getPlayerInstantSpellInfo(cid, i) -- Verifica se o feitiço não está no nível mínimo if(spell.mlevel ~= 1) then if(spell.manapercent > 0) then spell.mana = spell.manapercent .. "%" end table.insert(t, spell) end end -- Ordena os feitiços pelo nível de magia table.sort(t, function(a, b) return a.mlevel < b.mlevel end) -- Constrói a mensagem a ser exibida local text = "" local prevLevel = -1 for i, spell in ipairs(t) do local line = "" if(prevLevel ~= spell.mlevel) then if(i ~= 1) then line = "\n" end line = line .. "Spells for Magic Level " .. spell.mlevel .. "\n" prevLevel = spell.mlevel end text = text .. line .. " " .. spell.words .. " : " .. spell.mana .. "\n" end -- Verifica o comprimento do texto if #text > 5000 then local chunks = {} local current_chunk = "" for line in text:gmatch("[^\r\n]+") do if #current_chunk + #line > 5000 then table.insert(chunks, current_chunk) current_chunk = "" end current_chunk = current_chunk .. line .. "\n" end table.insert(chunks, current_chunk) -- Mostra cada fragmento de texto ao jogador for _, chunk in ipairs(chunks) do doShowTextDialog(cid, 2175, chunk) end else -- Mostra a mensagem ao jogador doShowTextDialog(cid, 2175, text) end return true end


info
Grupo: Artesão
Registrado: 01/03/20
Posts: 110
Reputação: +1
Gênero: Masculino
Char no Tibia: Samuel on Issobra