LUA:
function onSay(cid, words, param, channel)
local maxSpellsToShow = 8000 -- 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
table.insert(t, spell.words) -- Adiciona apenas o nome da magia à lista
end
end
-- Ordena os feitiços em ordem alfabética
table.sort(t)
-- Constrói a mensagem a ser exibida
local text = ""
local prevLevel = -1
for _, spellName in ipairs(t) do
text = text .. spellName .. "\n"
end
-- Verifica o comprimento do texto
if #text > 8000 then
local chunks = {}
local current_chunk = ""
for _, spellName in ipairs(t) do
if #current_chunk + #spellName > 8000 then
table.insert(chunks, current_chunk)
current_chunk = ""
end
current_chunk = current_chunk .. spellName .. "\n"
end
table.insert(chunks, current_chunk)
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