Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions data/actions/scripts/other/spellbook.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local count = getPlayerInstantSpellCount(player)
local text = ""
function onUse(cid, item, fromPosition, itemEx, toPosition)
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(player, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
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
t[#t + 1] = spell

table.insert(t, spell)
end
end

table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
local spell
for i = 1, #t do
spell = t[i]
local text, prevLevel = "", -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
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
player:showTextDialog(item.itemid, text)

doShowTextDialog(cid, item.itemid, text)
return true
end