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

[1.4.2] Skill Stages - Gesior.pl

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hi!
Who Can rewarite for me this to TFS 1.4.2?
+ replace in command !serverinfo (actually stages).

This is code for 1.2 but not working with 1.4.2 :(

Lua:
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}}
skillStages[SKILL_MAGLEVEL] = {{0,10},{6,5},{15,7},{80,5},{90,2},{99,1}}
  
function Player:onGainSkillTries(skill, tries)
    if APPLY_SKILL_MULTIPLIER == false then
        return tries
    end
  
local skillName
local skillRate
    if(skill==0)then
        skillName=SKILL_FIST
    elseif(skill==1)then
        skillName=SKILL_CLUB
    elseif(skill==2)then
        skillName=SKILL_SWORD
    elseif(skill==3)then
        skillName=SKILL_AXE
    elseif(skill==4)then
        skillName=SKILL_DISTANCE
    elseif(skill==5)then
        skillName=SKILL_SHIELD
    elseif(skill==6)then
        skillName=FISHING
    end
     if(skillStages[skill] ~= nil) then
        skillRate = 1
        for i, skillRateInfo in pairs(skillStages[skill]) do
            if(getPlayerSkill(self, skillName) >= skillRateInfo[1]) then
                skillRate = skillRateInfo[2]
            else
                break
            end
        end
    end
  
    if skill == SKILL_MAGLEVEL then
        return tries * configManager.getNumber(configKeys.RATE_MAGIC) * skillRate
    end
    return tries * configManager.getNumber(configKeys.RATE_SKILL) * skillRate
end
 
Dude, I don't see where the onSay function is. You said it's not working, it's obvious that it doesn't work without the onSay function to use the command... But you can learn and study more about Lua... Practicing and editing is very enjoyable to learn. Look, I understood that you wanted this 'serverinfo' command, so I went to check and realized that it's missing a lot... I went searching elsewhere and found it, and adapted it to RevScripts for you.

Revscriptsys.​

Lua:
SkillsTable = {
  [0] = { --[[ SKILL_FIST ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [1] = { --[[ SKILL_CLUB ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [2] = { --[[ SKILL_SWORD ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [3] = { --[[ SKILL_AXE ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [4] = { --[[ SKILL_DISTANCE ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 18,
      [{91, 110}] = 8,
      [{111, 300}] = 2
    },
    rate = configKeys.RATE_SKILL
  },
  [5] = { --[[ SKILL_SHIELD ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [6] = { --[[ SKILL_FISHING ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [7] = { --[[ SKILL_MAGLEVEL ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 5,
      [{111, 300}] = 1
    },
    rate = configKeys.RATE_MAGIC
  }
}

local talkaction = TalkAction("!serverinfo")


function talkaction.onSay(player, words, param)
  function getSkillsRate(level, skill)
    local skillRange = SkillsTable[skill]
    
    if skillRange and skillRange.stage then
      for _, sLevel in pairs(skillRange.stage) do
        if type(sLevel) == "table" and #sLevel == 2 then
          local minLevel, maxLevel = sLevel[1], sLevel[2]
          
          if minLevel and maxLevel and level >= minLevel and level <= maxLevel then
            return skillRange.rate
          end
        end
      end
    end
    
    return configManager.getNumber(skillRange.rate)
  end

  local playerLevel = player:getLevel()
  local expRate = Game.getExperienceStage(playerLevel)
 
  local fistRate = getSkillsRate(player:getEffectiveSkillLevel(0), 0)
  local clubRate = getSkillsRate(player:getEffectiveSkillLevel(1), 1)
  local swordRate = getSkillsRate(player:getEffectiveSkillLevel(2), 2)
  local axeRate = getSkillsRate(player:getEffectiveSkillLevel(3), 3)
  local distanceRate = getSkillsRate(player:getEffectiveSkillLevel(4), 4)
  local shieldingRate = getSkillsRate(player:getEffectiveSkillLevel(5), 5)
  local fishingRate = getSkillsRate(player:getEffectiveSkillLevel(6), 6)
  local magicRate = getSkillsRate(player:getEffectiveSkillLevel(7), 7)
  local lootRate = configManager.getNumber(configKeys.RATE_LOOT)
 
  player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Server Info:"
    .. "\nExp rate: " .. expRate
    .. "\nFist fighting rate: " .. fistRate
    .. "\nClub fighting rate: " .. clubRate
    .. "\nSword fighting rate: " .. swordRate
    .. "\nAxe fighting rate: " .. axeRate
    .. "\nDistance fighting rate: " .. distanceRate
    .. "\nShielding rate: " .. shieldingRate
    .. "\nFishing rate: " .. fishingRate
    .. "\nMagic rate: " .. magicRate
    .. "\nLoot rate: " .. lootRate)
    
  return false
end

talkaction:register()

original..
 
Dude, I don't see where the onSay function is. You said it's not working, it's obvious that it doesn't work without the onSay function to use the command... But you can learn and study more about Lua... Practicing and editing is very enjoyable to learn. Look, I understood that you wanted this 'serverinfo' command, so I went to check and realized that it's missing a lot... I went searching elsewhere and found it, and adapted it to RevScripts for you.

Revscriptsys.​

Lua:
SkillsTable = {
  [0] = { --[[ SKILL_FIST ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [1] = { --[[ SKILL_CLUB ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [2] = { --[[ SKILL_SWORD ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [3] = { --[[ SKILL_AXE ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [4] = { --[[ SKILL_DISTANCE ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 18,
      [{91, 110}] = 8,
      [{111, 300}] = 2
    },
    rate = configKeys.RATE_SKILL
  },
  [5] = { --[[ SKILL_SHIELD ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [6] = { --[[ SKILL_FISHING ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 10,
      [{111, 300}] = 3
    },
    rate = configKeys.RATE_SKILL
  },
  [7] = { --[[ SKILL_MAGLEVEL ]]
    stage = {
      [{10, 30}] = 100,
      [{31, 50}] = 70,
      [{51, 70}] = 40,
      [{71, 90}] = 20,
      [{91, 110}] = 5,
      [{111, 300}] = 1
    },
    rate = configKeys.RATE_MAGIC
  }
}

local talkaction = TalkAction("!serverinfo")


function talkaction.onSay(player, words, param)
  function getSkillsRate(level, skill)
    local skillRange = SkillsTable[skill]
   
    if skillRange and skillRange.stage then
      for _, sLevel in pairs(skillRange.stage) do
        if type(sLevel) == "table" and #sLevel == 2 then
          local minLevel, maxLevel = sLevel[1], sLevel[2]
         
          if minLevel and maxLevel and level >= minLevel and level <= maxLevel then
            return skillRange.rate
          end
        end
      end
    end
   
    return configManager.getNumber(skillRange.rate)
  end

  local playerLevel = player:getLevel()
  local expRate = Game.getExperienceStage(playerLevel)
 
  local fistRate = getSkillsRate(player:getEffectiveSkillLevel(0), 0)
  local clubRate = getSkillsRate(player:getEffectiveSkillLevel(1), 1)
  local swordRate = getSkillsRate(player:getEffectiveSkillLevel(2), 2)
  local axeRate = getSkillsRate(player:getEffectiveSkillLevel(3), 3)
  local distanceRate = getSkillsRate(player:getEffectiveSkillLevel(4), 4)
  local shieldingRate = getSkillsRate(player:getEffectiveSkillLevel(5), 5)
  local fishingRate = getSkillsRate(player:getEffectiveSkillLevel(6), 6)
  local magicRate = getSkillsRate(player:getEffectiveSkillLevel(7), 7)
  local lootRate = configManager.getNumber(configKeys.RATE_LOOT)
 
  player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Server Info:"
    .. "\nExp rate: " .. expRate
    .. "\nFist fighting rate: " .. fistRate
    .. "\nClub fighting rate: " .. clubRate
    .. "\nSword fighting rate: " .. swordRate
    .. "\nAxe fighting rate: " .. axeRate
    .. "\nDistance fighting rate: " .. distanceRate
    .. "\nShielding rate: " .. shieldingRate
    .. "\nFishing rate: " .. fishingRate
    .. "\nMagic rate: " .. magicRate
    .. "\nLoot rate: " .. lootRate)
   
  return false
end

talkaction:register()

original..
how can i setup it on players.lua?
 
Back
Top