• 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 0.X Skills stages + Movemment change skill

sucibob

Member
Joined
Mar 28, 2017
Messages
128
Reaction score
13
I used to have skills rates 10 magic level 5

config.lua
Code:
    rateSkill = 10.0
    rateMagic = 5.0

Until i found this skills stages script: CreatureEvent - Skills & magic level stages (https://otland.net/threads/skills-magic-level-stages.49165/)

But it broke a movemment i used to use:
Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    setPlayerStorageValue(cid, 17000, 5)
    doPlayerSetRate(cid, SKILL_FIST, 5)
    doPlayerSetRate(cid, SKILL_CLUB, 5)
    doPlayerSetRate(cid, SKILL_SWORD, 5)
    doPlayerSetRate(cid, SKILL_AXE, 5)
    doPlayerSetRate(cid, SKILL_DISTANCE, 5)
    doPlayerSetRate(cid, SKILL_SHIELD, 5)
    doPlayerSetRate(cid, SKILL_FISHING, 5)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 25)
    return true
end

function onStepOut(cid, item, position, fromPosition)
    setPlayerStorageValue(cid, 17000, 0)
    doPlayerSetRate(cid, SKILL_FIST, 10)
    doPlayerSetRate(cid, SKILL_CLUB, 10)
    doPlayerSetRate(cid, SKILL_SWORD, 10)
    doPlayerSetRate(cid, SKILL_AXE, 10)
    doPlayerSetRate(cid, SKILL_DISTANCE, 10)
    doPlayerSetRate(cid, SKILL_SHIELD, 10)
    doPlayerSetRate(cid, SKILL_FISHING, 10)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 5)
    return true
end

How to make it change skills depending on player skill stages?

can i do a:
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")

and check some how the player rates stages?



that is the way?
 
I tried this:
Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
    local mlRates = skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel
    local fistRates = skillInfo[SKILL_FIST] * skillConfig.skill
    local clubRates = skillInfo[SKILL_CLUB] * skillConfig.skill
    local swordRates = skillInfo[SKILL_SWORD] * skillConfig.skill
    local axeRates = skillInfo[SKILL_AXE] * skillConfig.skill
    local distRates = skillInfo[SKILL_DISTANCE] * skillConfig.skill
    local shieldRates = skillInfo[SKILL_SHIELD] * skillConfig.skill
    local fishingRates = skillInfo[SKILL_FISHING] * skillConfig.skill
    print(mlRates)
    print(swordRates)
    setPlayerStorageValue(cid, 17000, 1)
    doPlayerSetRate(cid, SKILL_FIST, 1)
    doPlayerSetRate(cid, SKILL_CLUB, 1)
    doPlayerSetRate(cid, SKILL_SWORD, 1)
    doPlayerSetRate(cid, SKILL_AXE, 1)
    doPlayerSetRate(cid, SKILL_DISTANCE, 1)
    doPlayerSetRate(cid, SKILL_SHIELD, 1)
    doPlayerSetRate(cid, SKILL_FISHING, 1)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 0.5)
    return true
end

function onStepOut(cid, item, position, fromPosition)
    setPlayerStorageValue(cid, 17000, 0)
    doPlayerSetRate(cid, SKILL_FIST, 2)
    doPlayerSetRate(cid, SKILL_CLUB, 2)
    doPlayerSetRate(cid, SKILL_SWORD, 2)
    doPlayerSetRate(cid, SKILL_AXE, 2)
    doPlayerSetRate(cid, SKILL_DISTANCE, 2)
    doPlayerSetRate(cid, SKILL_SHIELD, 2)
    doPlayerSetRate(cid, SKILL_FISHING, 2)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 1)
    return true
end

But got this error:
Code:
[11:30:51.106] [Error - MoveEvents Interface]
[11:30:51.107] data/movements/scripts/trainers_room.lua:onStepIn
[11:30:51.107] Description:
[11:30:51.107] data/movements/scripts/trainers_room.lua:3: attempt to index global 'skillInfo' (a nil value)
[11:30:51.107] stack traceback:
[11:30:51.107]     data/movements/scripts/trainers_room.lua:3: in function <data/movements/scripts/trainers_room.lua:1>
[11:30:51.107]     [C]: in function 'doTeleportThing'
[11:30:51.107]     data/movements/scripts/trainerstp.lua:12: in function <data/movements/scripts/trainerstp.lua:1>

What i've done wrong?

Is anyone know how to put it to work?
 
I tried this:
Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
    local mlRates = skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel
    local fistRates = skillInfo[SKILL_FIST] * skillConfig.skill
    local clubRates = skillInfo[SKILL_CLUB] * skillConfig.skill
    local swordRates = skillInfo[SKILL_SWORD] * skillConfig.skill
    local axeRates = skillInfo[SKILL_AXE] * skillConfig.skill
    local distRates = skillInfo[SKILL_DISTANCE] * skillConfig.skill
    local shieldRates = skillInfo[SKILL_SHIELD] * skillConfig.skill
    local fishingRates = skillInfo[SKILL_FISHING] * skillConfig.skill
    print(mlRates)
    print(swordRates)
    setPlayerStorageValue(cid, 17000, 1)
    doPlayerSetRate(cid, SKILL_FIST, 1)
    doPlayerSetRate(cid, SKILL_CLUB, 1)
    doPlayerSetRate(cid, SKILL_SWORD, 1)
    doPlayerSetRate(cid, SKILL_AXE, 1)
    doPlayerSetRate(cid, SKILL_DISTANCE, 1)
    doPlayerSetRate(cid, SKILL_SHIELD, 1)
    doPlayerSetRate(cid, SKILL_FISHING, 1)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 0.5)
    return true
end

function onStepOut(cid, item, position, fromPosition)
    setPlayerStorageValue(cid, 17000, 0)
    doPlayerSetRate(cid, SKILL_FIST, 2)
    doPlayerSetRate(cid, SKILL_CLUB, 2)
    doPlayerSetRate(cid, SKILL_SWORD, 2)
    doPlayerSetRate(cid, SKILL_AXE, 2)
    doPlayerSetRate(cid, SKILL_DISTANCE, 2)
    doPlayerSetRate(cid, SKILL_SHIELD, 2)
    doPlayerSetRate(cid, SKILL_FISHING, 2)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 1)
    return true
end

But got this error:
Code:
[11:30:51.106] [Error - MoveEvents Interface]
[11:30:51.107] data/movements/scripts/trainers_room.lua:onStepIn
[11:30:51.107] Description:
[11:30:51.107] data/movements/scripts/trainers_room.lua:3: attempt to index global 'skillInfo' (a nil value)
[11:30:51.107] stack traceback:
[11:30:51.107]     data/movements/scripts/trainers_room.lua:3: in function <data/movements/scripts/trainers_room.lua:1>
[11:30:51.107]     [C]: in function 'doTeleportThing'
[11:30:51.107]     data/movements/scripts/trainerstp.lua:12: in function <data/movements/scripts/trainerstp.lua:1>

What i've done wrong?

Is anyone know how to put it to work?
change
Code:
 local mlRates = skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel
to
Code:
 local mlRates = skillInfo[SKILL_MAGLEVEL] * skillConfig.magiclevel
 
change
Code:
 local mlRates = skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel
to
Code:
 local mlRates = skillInfo[SKILL_MAGLEVEL] * skillConfig.magiclevel

Code:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")
    local mlRates = skillInfo[SKILL_MAGLEVEL] * skillConfig.magiclevel
    local fistRates = skillInfo[SKILL_FIST] * skillConfig.skill
    local clubRates = skillInfo[SKILL_CLUB] * skillConfig.skill
    local swordRates = skillInfo[SKILL_SWORD] * skillConfig.skill
    local axeRates = skillInfo[SKILL_AXE] * skillConfig.skill
    local distRates = skillInfo[SKILL_DISTANCE] * skillConfig.skill
    local shieldRates = skillInfo[SKILL_SHIELD] * skillConfig.skill
    local fishingRates = skillInfo[SKILL_FISHING] * skillConfig.skill
    print(mlRates)
    print(swordRates)
    setPlayerStorageValue(cid, 17000, 1)
    doPlayerSetRate(cid, SKILL_FIST, 1)
    doPlayerSetRate(cid, SKILL_CLUB, 1)
    doPlayerSetRate(cid, SKILL_SWORD, 1)
    doPlayerSetRate(cid, SKILL_AXE, 1)
    doPlayerSetRate(cid, SKILL_DISTANCE, 1)
    doPlayerSetRate(cid, SKILL_SHIELD, 1)
    doPlayerSetRate(cid, SKILL_FISHING, 1)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 0.5)
    return true
end

function onStepOut(cid, item, position, fromPosition)
    setPlayerStorageValue(cid, 17000, 0)
    doPlayerSetRate(cid, SKILL_FIST, 2)
    doPlayerSetRate(cid, SKILL_CLUB, 2)
    doPlayerSetRate(cid, SKILL_SWORD, 2)
    doPlayerSetRate(cid, SKILL_AXE, 2)
    doPlayerSetRate(cid, SKILL_DISTANCE, 2)
    doPlayerSetRate(cid, SKILL_SHIELD, 2)
    doPlayerSetRate(cid, SKILL_FISHING, 2)
    doPlayerSetRate(cid, SKILL__MAGLEVEL, 1)
    return true
end

Code:
[4:37:33.750] [Error - MoveEvents Interface] 
[4:37:33.750] data/movements/scripts/trainers_room.lua:onStepIn
[4:37:33.750] Description: 
[4:37:33.750] data/movements/scripts/trainers_room.lua:3: attempt to index global 'skillInfo' (a nil value)
[4:37:33.750] stack traceback:
[4:37:33.751]     data/movements/scripts/trainers_room.lua:3: in function <data/movements/scripts/trainers_room.lua:1>
[4:37:33.751]     [C]: in function 'doTeleportThing'
[4:37:33.751]     data/movements/scripts/trainerstp.lua:12: in function <data/movements/scripts/trainerstp.lua:1>
 
Are the onStepin and onStepOut for the training room rates?
I would add a storage id for the players in there in that case that disables the Skills and magic level stages
or makes them lower if using a trainer than normaly

Not exactly shure what the situation is in the trainers_room script but if you can explain i could try to help
 
Are the onStepin and onStepOut for the training room rates?

Yes it is from onStepIn and onStepOut of training room

I would add a storage id for the players in there in that case that disables the Skills and magic level stages
or makes them lower if using a trainer than normaly

Not exactly shure what the situation is in the trainers_room script but if you can explain i could try to help
I don't understand what are u mean here

But as u can see there is a storage 17000


setPlayerStorageValue(cid, 17000, 1)
means player is on training room

setPlayerStorageValue(cid, 17000, 0)
means player is not on training room

i use it to others checks
 
I would only have the movement script only to set a storage id and not change the skills
then i would use the chreaturescript to change the rates if the storage is active

alsow make it so that the storage is set to 0 on login inside a protective zone
 
I would only have the movement script only to set a storage id and not change the skills
then i would use the chreaturescript to change the rates if the storage is active

alsow make it so that the storage is set to 0 on login inside a protective zone

Why?
Everything was working on movemments before i have the skills stages script

The problem is to acess the stages from /data/creaturescripts/scripts/stagesconfg.lua
Code:
skillConfig = {skill = getConfigValue('rateSkill'), magiclevel = getConfigValue('rateMagic')}
skillStages = {}
skillStages[SKILL_FIST] = {{0,8},{60,5},{80,3},{100,2}}
skillStages[SKILL_CLUB] = {{0,8},{60,5},{80,2},{100,1}}
skillStages[SKILL_SWORD] = {{0,8},{60,5},{80,2},{100,1}}
skillStages[SKILL_AXE] = {{0,8},{60,5},{80,2},{100,1}}
skillStages[SKILL_DISTANCE] = {{0,8},{60,5},{80,2},{100,1}}
skillStages[SKILL_SHIELD] = {{0,9},{60,8},{80,7},{100,6},{110,3}}
--skillStages[SKILL_FISHING] = {{0,5},{60,4},{80,3},{100,2},{110,1}} -- uncomment it to make it work, you can remove other skill config if you dont need it
skillStages[SKILL__MAGLEVEL] = {{0,10},{6,5},{15,7},{80,5},{90,2},{99,1}}
showInfoOnAdvance = true -- send player message about skill rate change
showInfoOnLogin = true -- send player message about skill rates when he login
 
function getPlayerSkillRatesText(cid)
 local skillInfo = getPlayerRates(cid)
 return "YOUR RATES: [ Magic Level: " .. skillInfo[SKILL__MAGLEVEL] * skillConfig.magiclevel .. "x || Fist: " .. skillInfo[SKILL_FIST] * skillConfig.skill .. "x | Club: " .. skillInfo[SKILL_CLUB] * skillConfig.skill .. "x |  Sword: " .. skillInfo[SKILL_SWORD] * skillConfig.skill .. "x | Axe: " .. skillInfo[SKILL_AXE] * skillConfig.skill .. "x |  Distance: " .. skillInfo[SKILL_DISTANCE] * skillConfig.skill .. " | Shielding: " .. skillInfo[SKILL_SHIELD] * skillConfig.skill .. "x | Fishing: " .. skillInfo[SKILL_FISHING] * skillConfig.skill .. "x ]"
end

 
I understand that but everytime you advance your skillrate will change for the one in creaturescripts
 
I understand that but everytime you advance your skillrate will change for the one in creaturescripts

And it couldn't be fixed by
Code:
dofile(getDataDir() .. "creaturescripts/scripts/stagesconfig.lua")

function onAdvance(cid, skill, oldLevel, newLevel)
    if(skillStages[skill] ~= nil) then
        local skillRate = 1
        local oldRates = getPlayerRates(cid)
        for i, skillRateInfo in pairs(skillStages[skill]) do 
            if(newLevel >= skillRateInfo[1]) then
                skillRate = skillRateInfo[2]
            else
                break
            end
        end
        doPlayerSetRate(cid, skill, skillRate)
        if(showInfoOnAdvance and skillRate ~= oldRates[skill]) then
            if(skill >= 0 and skill <= 6) then
                configRate = skillConfig.skill
                -- in trainers
                if getPlayerStorageValue(cid, 17000) > 0 then
                    configRate = configRate / 2
                end
            else
                configRate = skillConfig.magiclevel
                -- in trainers
                if getPlayerStorageValue(cid, 17000) > 0 then
                    configRate = configRate / 2
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, SKILL_NAMES[skill] .. " rate changed from " .. oldRates[skill] * configRate .. "x to " .. skillRate * configRate .. "x. " .. getPlayerSkillRatesText(cid))
        end
    end
    return true
end

???
 
Back
Top