• 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+ attempt to index global 'vocation' (a nil value)

anderkrox

New Member
Joined
May 14, 2020
Messages
21
Reaction score
1
Lua Script Error: [Spell Interface]
in callback: data/spells/scripts/attack/sudden_death_rune.lua:eek:nGetFormulaValues
(Unknown scriptfile)
data/spells/scripts/attack/sudden_death_rune.lua:37: attempt to index global 'vocation' (a nil value)
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

local function removerExaustao(playerID)
    local player = Player(playerID)
    if player:isPlayer() then
        player:setStorageValue(CAST_EXHAUST, 0)
    end
    return true
end

function onGetFormulaValues(player, level, maglevel)
    local max = -((level / 5) + (maglevel * 7.4) + 48)
    local min = -(max*0.7)

    if getConfigInfo(danoDiferentePorClasse) == true then
        if vocation:getName() == "Feiticeiro" then
            max = (max*1.1)
            min = (min*1.0)
        end
        if vocation:getName() == ("Arqueiro" or "Bruxo") then
            max = (max*0.9)
            min = (min*0.8)
        end
        if vocation:getName() == ("Barbaro" or "Paladino") then
            max = (max*0.7)
            min = (min*0.6)
        end
        if vocation:getName() == ("Clerigo" or "Atirador" or "Conjurador" or "Druida") then
            max = (max*0.5)
            min = (min*0.4)
        end
    end
    if player:getStorageValue(CAST_EXHAUST) <= 0 then
        if vocation:getName() == ("Clerigo" or "Bruxo") then
            addEvent(removerExaustao, CAST_ATAQUE_3, player:getid())
        end
        if vocation:getName() == "Arqueiro" then
            addEvent(removerExaustao, CAST_ATAQUE_2, player:getid())
        end
        if vocation:getName() == ("Barbaro" or "Paladino" or "Atirador" or "Feiticeiro" or "Conjurador" or "Druida") then
            addEvent(removerExaustao, CAST_ATAQUE_1, player:getid())
        end
        player:setStorageValue(CAST_EXHAUST, 1)       
        return min, max
    else
        player.sendCancelMessage(player, "Esta exausto.")
        player:sendMagicEffect(CONST_ME_POFF)
    end
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var, isHotkey)
    return combat:execute(creature, var)
end
 
I don't really think you could use getName() to get vocation name (nor use 'vocation' without defining it anywhere), but you would do better by using ids, something like this:


if table.contains({1, 3, 4}, player:getVocation():getId()) then
 
Back
Top