Kodak
Member
- Joined
- Jun 7, 2007
- Messages
- 36
- Reaction score
- 6
So I started with Geisors script for Skill Stages and Mag level stages, then while searching found a code wrote by Ninja for player.lua for stages. I've gotten normal skills work, sword, distance, etc, but I get an error when magic spells are used, and the correct rates are not applied. TFS 1.2
Error:
This is the line of code:
Error:
Code:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onGainSkillTries
data/events/scripts/player.lua:388: attempt to compare number with nil
stack traceback:
[C]: in function '__le'
data/events/scripts/player.lua:388: in function 'getSkillRate'
data/events/scripts/player.lua:403: in function <data/events/scripts/player.lua:398>
This is the line of code:
Code:
local config = {
-- base vocationId
[1] = {
-- skillId
[SKILL_FIST] = {
-- [{skillLevel}] = skillRate
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_CLUB] = {
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_SWORD] = {
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_AXE] = {
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_DISTANCE] = {
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_SHIELD] = {
[{10, 20}] = 10,
[{20, 100}] = 2
},
[SKILL_FISHING] = {
[{10, 20}] = 10,
[{20, 100}] = 5
},
[SKILL_MAGLEVEL] = {
[{0, 6}] = 10,
[{7, 15}] = 7,
[{16, 80}] = 5,
[{81, 99}] = 2
}
},
Code:
local function getSkillRate(player, skillId)
local targetVocation = config[player:getVocation():getBase():getId()]
if targetVocation then
local targetSkillStage = targetVocation[skillId]
if targetSkillStage then
local skillLevel = player:getSkillLevel(skillId)
for level, rate in pairs(targetSkillStage) do
if skillLevel >= level[1] and skillLevel <= level[2] then
return rate
end
end
end
end
return skillId == SKILL_MAGLEVEL and configManager.getNumber(configKeys.RATE_MAGIC) or configManager.getNumber(configKeys.RATE_SKILL)
end
function Player:onGainSkillTries(skill, tries)
if not APPLY_SKILL_MULTIPLIER then
return tries
end
return tries * getSkillRate(self, skill)
end