• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.x A working !spells command.

Eazzy

New Member
Joined
Mar 25, 2019
Messages
8
Solutions
1
Reaction score
1
I've been searching around for a functioning !spells command but can't seem to find one for TFS 1.1-3, would be lovely to have one.

New to this,
Regards,
Eazzy
 
Solution
data/talkactions/talkactions.xml
Code:
<talkaction words="!spells" script="spells.lua" />

data/talkactions/scripts/spells.lua

Lua:
function onSay(player, words, param)
    local text = ""
    local spells = {}
    for _, spell in ipairs(player:getInstantSpells()) do
        if spell.level ~= 0 then
            if spell.manapercent > 0 then
                spell.mana = spell.manapercent .. "%"
            end
            spells[#spells + 1] = spell
        end
    end

    table.sort(spells, function(a, b) return a.level < b.level end)

    local prevLevel = -1
    for i, spell in ipairs(spells) do
        local line = ""
        if prevLevel ~= spell.level then
            if i ~= 1 then
                line = "\n"
            end...
data/talkactions/talkactions.xml
Code:
<talkaction words="!spells" script="spells.lua" />

data/talkactions/scripts/spells.lua

Lua:
function onSay(player, words, param)
    local text = ""
    local spells = {}
    for _, spell in ipairs(player:getInstantSpells()) do
        if spell.level ~= 0 then
            if spell.manapercent > 0 then
                spell.mana = spell.manapercent .. "%"
            end
            spells[#spells + 1] = spell
        end
    end

    table.sort(spells, function(a, b) return a.level < b.level end)

    local prevLevel = -1
    for i, spell in ipairs(spells) do
        local line = ""
        if prevLevel ~= spell.level then
            if i ~= 1 then
                line = "\n"
            end
            line = line .. "Jutsu para o nível " .. spell.level .. "\n"
            prevLevel = spell.level
        end
        text = text .. line .. "  " .. spell.words .. " : " .. spell.mana .. "\n"
    end

    player:showTextDialog(1692, text)
    return true
end
 
Solution
Back
Top