ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
- Joined
- Dec 17, 2011
- Messages
- 1,759
- Solutions
- 31
- Reaction score
- 999
- Location
- Santiago - Chile
- GitHub
- ralke23
- Twitch
- ralke23
Using OTX 2 (0.3.7)
Hi again, there's some monsters on my server that needs custom spells, the problem is that the spells are appearing on spellbooks and !spell commands. Tried with enabled = 0 on spells.xml but doesn't work. Here's an image explaining it better.

The ideas that comes to my mind are:
[1] Set a level limit to the spells that are shown (only show spells that are less that "level 9999").
[2] Make an onUse script that show spells as doPlayerSendTextMessage depending of player vocation, the annoying thing is that I will have to manually write all spells and it's statics.
Please help me with this! I'm sure the first idea could work better, or there might be another ways to make it work as intended (you guys know how to do it better than me).
Spellbook
Talkaction
Here's another reference script that might be usefull for the second idea (using tables)
Thanks in advance!
Hi again, there's some monsters on my server that needs custom spells, the problem is that the spells are appearing on spellbooks and !spell commands. Tried with enabled = 0 on spells.xml but doesn't work. Here's an image explaining it better.

The ideas that comes to my mind are:
[1] Set a level limit to the spells that are shown (only show spells that are less that "level 9999").
[2] Make an onUse script that show spells as doPlayerSendTextMessage depending of player vocation, the annoying thing is that I will have to manually write all spells and it's statics.
Please help me with this! I'm sure the first idea could work better, or there might be another ways to make it work as intended (you guys know how to do it better than me).
Spellbook
Code:
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
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
doShowTextDialog(cid, item.itemid, text)
return true
end
Talkaction
Code:
function onSay(cid, words, param)
local count = getPlayerInstantSpellCount(cid)
local text = ""
local t = {}
for i = 0, count - 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
table.sort(t, function(a, b) return a.level < b.level end)
local 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
doShowTextDialog(cid, 2175, text)
return TRUE
end
Here's another reference script that might be usefull for the second idea (using tables)
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
if skill == SKILL__LEVEL then
local spells = {}
for index = 0, getPlayerInstantSpellCount(cid) - 1 do
local spell = getPlayerInstantSpellInfo(cid, index)
if spell.level > oldLevel and spell.level <= newLevel then
table.insert(spells, " [".. spell.name .."] \"".. spell.words .. "\" Mana[".. spell.mana .."]")
end
end
if #spells > 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have just advanced to level ".. newLevel .." and learned new spells!")
for _, v in pairs(spells) do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, v)
end
end
end
return true
end
Thanks in advance!
Last edited: