• 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+ Skill Stages Error

aqubjukr

Well-Known Member
Joined
Mar 13, 2013
Messages
200
Solutions
17
Reaction score
79
Location
Paraná, Brazil
I'm trying to implement a skill stages system on my server. It even works, however, when I use any spell with a player, the following error appears on my console:

TFS1.3

Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainSkillTries
data/events/scripts/player.lua:896: bad argument #1 to 'next' (table expected, got nil)
stack traceback:
        [C]: at 0x005be450
        [C]: in function 'next'
        data/events/scripts/player.lua:896: in function <data/events/scripts/player.lua:891>
 

Attachments

Last edited:
Solution
Any errors in console?
From if in 6th line remove skills.rate

Tomorrow I will try it in my server and respond here if will work

@Edit

Alright, this should work for stages
Lua:
function getSkillsRate(level, stages)
    if stages then
        for sLevel, multiplier in pairs(stages) do
            if level >= sLevel[1] and level <= sLevel[2] then
                return multiplier
            end
        end
    end
    return 1
end

function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return tries
    end
    local skills = SkillsTable[skill]
    if skills then
        if skill == SKILL_MAGLEVEL then
            return tries * getSkillsRate(self:getMagicLevel(), skills.stage)
        end...
Yep man. I was trying to solve this, and I got to make the magic level stages work, but the others stopped: /

Lua:
function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
    return tries
  end
  local skills = SkillsTable[skill]
  if skills and skills.rate then
    local rate = configManager.getNumber(skills.rate)
    if rate > 0 then
      return tries * rate
    else
      return tries * rate
    end
  end
    if skill == SKILL_MAGLEVEL then
    local ratemagic = configKeys.RATE_MAGIC
    if ratemagic > 0 then
      return tries * ratemagic
    else
      return tries * ratemagic
    end
end
end

Now i'm trying to get both.
 
It will never reach if in 14th line, becouse earlier if will return some value for any skill so you may remove it
Try changing line 7 to this
local rate = skills.rate
rate field from skills variable already holds skill rate from config according to player.lua file you have shared

------

Nope, I am wrong about rate part
 
Last edited:
Any errors in console?
From if in 6th line remove skills.rate

Tomorrow I will try it in my server and respond here if will work

@Edit

Alright, this should work for stages
Lua:
function getSkillsRate(level, stages)
    if stages then
        for sLevel, multiplier in pairs(stages) do
            if level >= sLevel[1] and level <= sLevel[2] then
                return multiplier
            end
        end
    end
    return 1
end

function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return tries
    end
    local skills = SkillsTable[skill]
    if skills then
        if skill == SKILL_MAGLEVEL then
            return tries * getSkillsRate(self:getMagicLevel(), skills.stage)
        end
        return tries * getSkillsRate(self:getSkillLevel(skill), skills.stage)
    end
    return tries
end

Magic level was not working for you, because it is not hold in the same place as rest of skills so for this you need to use getMagicLevel
 
Last edited:
Solution
OMG man, you've helped me a loot! I was breaking my mind and it was not so difficult.

Ps: I've tested all skills and everyone is working normally.
 
Back
Top