• 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!

spell up error

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
someone min help with this error?

tfs 1.3

PHP:
local s = {
    repeatAfterDeath = false,
    detailedInfo = true,
    Storage = 70000,
    messageType = 'channel', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_STATUS_CONSOLE_ORANGE
    }
 
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL_LEVEL or not s.repeatAfterDeath and getPlayerStorageValue(cid, s.Storage) >= newlevel then
        return true
    end

    local t = {}
    for i = 0, getPlayerInstantSpellCount(cid) - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if(spell.level ~= 0) and spell.level == newlevel 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 .. 'New spells available (Level '..newlevel..'):\n'
            prevLevel = spell.level
        end
        text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana: '..spell.mana..''..(spell.mlevel > 0 and ' ML: '..spell.mlevel..'' or '') or '')..'\n'
    end
 
    if text == '' then
        return true
    end
 
    setPlayerStorageValue(cid, s.Storage, newlevel)
    doPlayerSendTextMessage(cid, s.channelClass, text)
    -- if s.messageType == 'popUp' then
        -- doShowTextDialog(cid, 2175, text)
    -- elseif s.messageType == 'channel' then
        -- doPlayerSendTextMessage(cid, s.channelClass, text)
    -- end
    return true
end

error:
PHP:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/spellup.lua:onAdvance
data/creaturescripts/scripts/spellup.lua:19: attempt to index local 'spell' (a boolean value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/spellup.lua:19: in function <data/creaturescripts/scripts/spellup.lua:11>
 
You do know this is Lua not PHP right?
LUA:
local s = {
    repeatAfterDeath = false,
    detailedInfo = true,
    Storage = 70000,
    messageType = 'channel', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_STATUS_CONSOLE_ORANGE
    }
 
function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL_LEVEL or not s.repeatAfterDeath and getPlayerStorageValue(cid, s.Storage) >= newlevel then
        return true
    end

    local t = {}
    for i = 0, getPlayerInstantSpellCount(cid) - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if spell then
            if(spell.level ~= 0) and spell.level == newlevel then
                if(spell.manapercent > 0) then
                    spell.mana = spell.manapercent .. '%'
                end
                table.insert(t, spell)
            end
        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 .. 'New spells available (Level '..newlevel..'):\n'
            prevLevel = spell.level
        end
        text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana: '..spell.mana..''..(spell.mlevel > 0 and ' ML: '..spell.mlevel..'' or '') or '')..'\n'
    end
 
    if text == '' then
        return true
    end
 
    setPlayerStorageValue(cid, s.Storage, newlevel)
    doPlayerSendTextMessage(cid, s.channelClass, text)
    -- if s.messageType == 'popUp' then
        -- doShowTextDialog(cid, 2175, text)
    -- elseif s.messageType == 'channel' then
        -- doPlayerSendTextMessage(cid, s.channelClass, text)
    -- end
    return true
end
 
You do know this is Lua not PHP right?
LUA:
local s = {
    repeatAfterDeath = false,
    detailedInfo = true,
    Storage = 70000,
    messageType = 'channel', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
    channelClass = MESSAGE_STATUS_CONSOLE_ORANGE
    }

function onAdvance(cid, skill, oldlevel, newlevel)
    if skill ~= SKILL_LEVEL or not s.repeatAfterDeath and getPlayerStorageValue(cid, s.Storage) >= newlevel then
        return true
    end

    local t = {}
    for i = 0, getPlayerInstantSpellCount(cid) - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if spell then
            if(spell.level ~= 0) and spell.level == newlevel then
                if(spell.manapercent > 0) then
                    spell.mana = spell.manapercent .. '%'
                end
                table.insert(t, spell)
            end
        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 .. 'New spells available (Level '..newlevel..'):\n'
            prevLevel = spell.level
        end
        text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana: '..spell.mana..''..(spell.mlevel > 0 and ' ML: '..spell.mlevel..'' or '') or '')..'\n'
    end

    if text == '' then
        return true
    end

    setPlayerStorageValue(cid, s.Storage, newlevel)
    doPlayerSendTextMessage(cid, s.channelClass, text)
    -- if s.messageType == 'popUp' then
        -- doShowTextDialog(cid, 2175, text)
    -- elseif s.messageType == 'channel' then
        -- doPlayerSendTextMessage(cid, s.channelClass, text)
    -- end
    return true
end
sorry
tested and crashed the server
 
Back
Top