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

Lua If under level, put level skills remains

Joriku

Working in the mines, need something?
Premium User
Joined
Jul 16, 2016
Messages
1,141
Solutions
15
Reaction score
432
Location
Sweden
Is it possible to put a start level as let's say X (Random number, I'll use 120).
And if a player goes under level 120 that player will be put back to level 120.
Let's say Iam level 8 and login, i'll instant be putted into level 120 with skills X X X (Sword, axe, magic etc.)
The level will be brought to 120 but skills will remain as it is. And if skills goes under X (I'll use for example magic 80) The magic level will be put to 80 if below that level.
Every vocation will have diffrent
Reason for keeping skills = which you prob. know already, the better skills the better dmg
for example:
all vocs:
Level 120.
Knight:
Axe:80
Sword:80
Club:80
Shield:80
Magic:15

Paladin:
Distance:90
Shield:80
Magic:20

Druid/Sorc:
Magic:80
Shield:80

Source:
This source is for 10.77 and the war config is:
Code:
-- The Forgotten [WAR] Server (TFS 1.2 for Tibia 10.77)
-- This server is the successor to The 8.4-8.6 release Simple War OT
-- Credit to Mark Samman & all contributers to The Forgotten Server
-- Credit to Shawak for inspiring this style of configuration
-- Credit to Ninja & Printer for two scripts that I have adapted for the server (individually credited and referenced in the scripts)


    startLevel = 120             -- What level do players start at?
    maximumLevel = 10000            -- What is the maximum level players can reach?
    promoteOnLogin = "yes"        -- Should players be promoted on login?
    fullBlessOnLogin = "yes"        -- Should players get full bless on login? This stops them dropping eq.
    enableStartSkills = "no"        -- Should players start with preset skills (see lists below)
    enableMinimumSkills = "no"        -- Ensures players do not fall below the skills set in this file
    enableMinimumLevel = "no"        -- Ensures players do not fall below the minimum level set in this file
    giveFirstItems = "yes"        -- Should new players receive first items? (see lists below)

    potionsInPz = "yes"             -- Can players use Potions in PZ?
    potionsRemoveOnUse = "no"        -- Do potions run out?
    changeCoins = "no"             -- Can players change coins? platinum -> gold etc.
    displayStatsOnLogin = "yes"    -- Should stats and minimum skills display each login?

    expMultiplier = 0.015            -- PVP-E Exp multiplier (enemy experience * expMultiplier)
    rewardItem = 2152            -- What is the item ID of the frag reward? (default: 2152 platinum coin)
    rewardCount = 1                -- How many of the above item should the killer receive?

    bonusFragReward = 5            -- How many bonus frag reward kills should each new player receive?
    bonusExpReward = 5            -- How many bonus exp reward kills should each new player receive?
    bonusExpMultiplier = 0.0075    -- How much extra exp should players get? (enemy experience * this value)

-- LOGIN MESSAGES
    newPlayerMessage = "Welcome to The Forgotten WAR Server. As a new player you have been gifted 5 bonus gold & exp frags! This server is the successor to the popular 'Simple War OT' release. Please note that the server is still in BETA testing."
    everyLoginMessage = "Please be aware that this server is still in BETA testing. Report all issues directly to [email protected] - Thank you"

-- MAP CONFIGURATION
    rotateMaps = "no"            -- Should the map automatically change? Interval set in globalevents.xml (default 30 minutes)
    numberOfMaps = 5            -- Number of maps to rotate between?
    startMap = 1                -- Which map should the server start on?
    mapChangeText = "The map has been changed! Next change in 30 minutes!"

    mapPositions = {
        [1] = {x=32369, y=32241, z=7},
        [2] = {x=32957, y=32076, z=7},
        [3] = {x=32360, y=31782, z=7},
        [4] = {x=33217, y=31814, z=8},
        [5] = {x=32097, y=32219, z=7},
        [6] = {x=1000, y=1000, z=7}
    }

----MINIMUM PLAYER STATS---------------------------------------                        
--ALL PLAYERS--
    minimumLevel = 120
    minimumLevelUp1 = 140

--SORCERER--
    sorcererMagic = 70
    sorcererMagicUp1 = 80

    sorcererShield = 25
    sorcererShieldUp1 = 30

--DRUID--
    druidMagic = 70
    druidMagicUp1 = 80

    druidShield = 25
    druidShieldUp1 = 30

--PALADIN--
    paladinMagic = 20
    paladinMagicUp1 = 25

    paladinShield = 70
    paladinShieldUp1 = 80

    paladinDistance = 95
    paladinDistanceUp1 = 105

--KNIGHT--
    knightMagic = 9
    knightMagicUp1 = 10

    knightShield = 85
    knightShieldUp1 = 95

    knightMelee = 90
    KnightMeleeUp1 = 100

----POTION RESTORE---------------------------------------------
    smhpL = 60    -- Small health potion. These values are the lowest and highest possible restores.
    smhpH = 90

    hpL = 125    -- Health potion
    hpH = 175

    mpL = 75    -- Mana potion
    mpH = 125

    shpL = 250    -- Strong health potion
    shpH = 350

    smpL = 115    -- Strong mana potion
    smpH = 185

    gsphL = 270    -- Great spirit potion (health)
    gsphH = 330
    gspmL = 130    -- Great spirit potion (mana)
    gspmH = 170

    ghpL = 425    -- Great health potion
    ghpH = 575

    gmpL = 150    -- Great mana potion
    gmpH = 250

    uhpL = 650    -- Ultimate health potion
    uhpH = 850

----FIRST ITEMS------------------------------------------------
commonItems = {
                ---------ALL VOCATIONS---------
  {itemid=1988, count=1},     -- backpack
  {itemid=2120, count=1},     -- rope
  {itemid=5710, count=1},     -- shovel
  {itemid=2420, count=1},     -- machete
  {itemid=2789, count=10},    -- brown mushrooms
  {itemid=2305, count=1},     -- fire bomb rune
  {itemid=2261, count=1},     -- destroy field rune
}

firstItems = {
            
  {                 ---------SORCERER ITEMS---------
    {itemid=2323, count=1},     -- hat of the mad         
    {itemid=8871, count=1},     -- focus cape             
    {itemid=7730, count=1},     -- blue legs             
    {itemid=2195, count=1},     -- boots of haste         
    {itemid=8902, count=1},     -- spellbook of mind control
    {itemid=2187, count=1},     -- wand of inferno       
                            
    {itemid=2268, count=1},     -- sd
    {itemid=2273, count=1},     -- uh
    {itemid=7590, count=1},     -- gmp
    {itemid=2293, count=1},     -- mw
  },
  {                 ---------DRUID ITEMS---------
    {itemid=2323, count=1},     -- hat of the mad
    {itemid=8871, count=1},     -- focus cape
    {itemid=7730, count=1},     -- blue legs
    {itemid=2195, count=1},     -- boots of haste
    {itemid=8902, count=1},     -- spellbook of mind control
    {itemid=2183, count=1},     -- hailstorm rod

    {itemid=2268, count=1},     -- sd
    {itemid=2273, count=1},     -- uh
    {itemid=7590, count=1},     -- gmp
    {itemid=2293, count=1},     -- mw
    {itemid=2269, count=1},     -- wg
    {itemid=2278, count=1},     -- para
  },
  {                 ---------PALADIN ITEMS---------
    {itemid=2493, count=1},     -- demon helmet
    {itemid=8891, count=1},     -- paladin armor
    {itemid=7730, count=1},     -- blue legs
    {itemid=2195, count=1},     -- boots of haste
    {itemid=2514, count=1},     -- mastermind shield
    {itemid=7368, count=1},     -- assassin stars

    {itemid=2268, count=1},     -- sd
    {itemid=2273, count=1},     -- uh
    {itemid=8472, count=1},     -- gsp
    {itemid=7589, count=1},     -- smp
    {itemid=7588, count=1},     -- shp
    {itemid=2293, count=1},     -- mw
  },
  {                 ---------KNIGHT ITEMS---------
    {itemid=2493, count=1},     -- demon helmet
    {itemid=2472, count=1},     -- magic plate armor
    {itemid=2470, count=1},     -- golden legs
    {itemid=2195, count=1},     -- boots of haste
    {itemid=2514, count=1},     -- mastermind shield
    {itemid=2400, count=1},     -- magic sword

    {itemid=7620, count=1},     -- mp
    {itemid=7591, count=1},     -- ghp
    {itemid=8473, count=1},     -- uhp
    {itemid=2273, count=1},     -- uh
    {itemid=2293, count=1},     -- mw
  }
}

-- PLAYER STORAGES
    doubleFragRewardStor = 24021
    extraExpStor = 24022
    minimumLevelUp1Stor = 24023
    sorcererMagicUp1Stor = 24024
    sorcererShieldUp1Stor = 24025
    druidMagicUp1Stor = 24026
    druidShieldUp1Stor = 24027
    paladinMagicUp1Stor = 24028
    paladinShieldUp1Stor = 24029
    paladinDistanceUp1Stor = 24030
    knightMagicUp1Stor = 24031
    knightShieldUp1Stor = 24032
    knightMeleeUp1Stor = 24033
    fragStor = 24034
    deathStor = 24035
-- GLOBAL STORAGES
    currentMap = 34021

Example on script startup
Globalevents:
Code:
<!-- Config -->
<globalevent type="startup" name="WarStartup" script="config/war_startup.lua"/>

Script:
Code:
dofile("war_config.lua")

function onStartup()
    setGlobalStorageValue(currentMap, startMap)
end
 
Best will be onLogin function.
It will trigger everytime you die, becouse you have to login after death.


Here is script I wrote for you. You just have to finish it with functions setSkillLevel, setMagicLevel and setLevel. You can get code from talkactions/scripts/add_skill.lua or somewhere from otland.

Here is 3/4 of work:

LUA:
local minLevels = {
    [1] = { -- vocation id
        level = 120,
        magic = 50,
        skills = 90,
        dist = 100,
        shield = 90,
    },
    [2] = {

    }
}

function setLevel(value) return true end
function setSkillLevel(skill, value) return true end
function setMagicLevel(value) return true end

function onLogin(player)
    local c = minLevels[player:getVocation():getId()]
    if player:getLevel() < c.level then
        player:setLevel(c.level)
    end
    for i = 0, 3 do
        if player:getSkillLevel(i) < c.skills then
            player:setSkillLevel(i, c.skills)
        end
    end
    if player:getSkillLevel(4) < c.dist then
        player:setSkillLevel(4, c.dist)
    end
    if player:getSkillLevel(5) < c.shield then
        player:setSkillLevel(5, c.shield)
    end
    if player:getMagicLevel() < c.magic then
        player:setMagicLevel(c.magic)
    end
    return true
end
 
Last edited:
Best will be onLogin function.
It will trigger everytime you die, becouse you have to login after death.


Here is script I wrote for you. You just have to finish it with functions setSkillLevel, setMagicLevel and setLevel. You can get code from talkactions/scripts/add_skill.lua or somewhere from otland.

LUA:
local minLevels = {
    [1] = { -- vocation id
        level = 120,
        magic = 50,
        skills = 90,
        dist = 100,
        shield = 90,
    },
    [2] = {

    }
}

function setLevel(value) return true end
function setSkillLevel(skill, value) return true end
function setMagicLevel(value) return true end

function onLogin(player)
    local c = minLevels[player:getVocation():getId()]
    if player:getLevel() < c.level then
        player:setLevel(c.level)
    end
    for i = 0, 3 do
        if player:getSkillLevel(i) < c.skills then
            player:setSkillLevel(i, c.skills)
        end
    end
    if player:getSkillLevel(4) < c.dist then
        player:setSkillLevel(4, c.dist)
    end
    if player:getSkillLevel(5) < c.shield then
        player:setSkillLevel(5, c.shield)
    end
    if player:getMagicLevel() < c.magic then
        player:setMagicLevel(c.magic)
    end
    return true
end
Iam affriad I don't copy what you mean..
And this code, like this?
Creaturescripts.xml?
LUA:
<event type="login" name="1login" script="others/config.lua"/>
LUA:
local minLevels = {
    [1] = { -- 1
        level = 120,
        magic = 9,
        skills = 90,
        dist = 0,
        shield = 80,
    },
    [2] = { -- 2
        level = 120,
        magic = 25,
        skills = 0,
        dist = 90,
        shield = 80,
    },
    [3] = { -- 3
        level = 120,
        magic = 80,
        skills = 0,
        dist = 0,
        shield = 80,
    },
    [4] = { -- 4
        level = 120,
        magic = 80,
        skills = 0,
        dist = 0,
        shield = 80,
    }
}

function setLevel(value) return true end
function setSkillLevel(skill, value) return true end
function setMagicLevel(value) return true end

function onLogin(player)
    local c = minLevels[player:getVocation():getId()]
    if player:getLevel() < c.level then
        player:setLevel(c.level)
    end
    for i = 0, 3 do
        if player:getSkillLevel(i) < c.skills then
            player:setSkillLevel(i, c.skills)
        end
    end
    if player:getSkillLevel(4) < c.dist then
        player:setSkillLevel(4, c.dist)
    end
    if player:getSkillLevel(5) < c.shield then
        player:setSkillLevel(5, c.shield)
    end
    if player:getMagicLevel() < c.magic then
        player:setMagicLevel(c.magic)
    end
    return true
end
 
I think you can use next, and remember to put it on login function.
Go to "data/creaturescripts/creaturescripts.xml" and add this line inside:
XML:
<event type="login" name="expSkill" script="checkExpSkill.lua"/>
now in folder "data/creaturescripts/scripts" create a file called: "checkExpSkill.lua" and paste this (I haven't tested it, but it would have to work)
LUA:
function getExperienceForLevel(level)
        level = level - 1
        return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
function Player.checkLevel(self, lv)
    if self:getLevel() < lv then
        local expLvl = getExperienceForLevel(lv) - self:getExperience()
        self:addExperience(expLvl, false)
        return true
    end
    return false
end
function Player.checkSkill(self, skill, lv) --     SKILL_FIST, SKILL_CLUB, SKILL_AXE, SKILL_SWORD, SKILL_SHIELD, SKILL_DISTANCE
    if self:getSkillLevel(skill) < lv then
        local tries = math.ceil(self:getVocation():getRequiredSkillTries(skill, lv) - self:getSkillTries(skill))
        self:addSkillTries(skill, tries)
        return true
    end
    return false
end
function Player.checkMagic(self, lv)
    if self:getMagicLevel() < lv then
        local mana = math.ceil(self:getVocation():getRequiredManaSpent(lv) - self:getManaSpent())
        self:addManaSpent(mana)
        return true
    end
    return false
end

function onLogin(player)
    local voc = player:getVocation():getId()
    if voc == 1 or voc == 2  or voc == 5 or voc == 6 then
        player:checkMagic(60)
        --player:checkSkill(SKILL_SHIELD, 20)
    elseif voc == 3 or voc == 7 then
        player:checkSkill(SKILL_DISTANCE, 60)
        player:checkSkill(SKILL_SHIELD, 40)
        --player:checkMagic(15)
    elseif voc == 4 or voc == 8 then
        player:checkSkill(SKILL_AXE, 60)
        player:checkSkill(SKILL_CLUB, 60)
        player:checkSkill(SKILL_SWORD, 40)
        player:checkSkill(SKILL_SHIELD, 40)
        --player:checkMagic(8)
    end
return TRUE
end
 
I think you can use next, and remember to put it on login function.
Go to "data/creaturescripts/creaturescripts.xml" and add this line inside:
XML:
<event type="login" name="expSkill" script="checkExpSkill.lua"/>
now in folder "data/creaturescripts/scripts" create a file called: "checkExpSkill.lua" and paste this (I haven't tested it, but it would have to work)
LUA:
function getExperienceForLevel(level)
        level = level - 1
        return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
function Player.checkLevel(self, lv)
    if self:getLevel() < lv then
        local expLvl = getExperienceForLevel(lv) - self:getExperience()
        self:addExperience(expLvl, false)
        return true
    end
    return false
end
function Player.checkSkill(self, skill, lv) --     SKILL_FIST, SKILL_CLUB, SKILL_AXE, SKILL_SWORD, SKILL_SHIELD, SKILL_DISTANCE
    if self:getSkillLevel(skill) < lv then
        local tries = math.ceil(self:getVocation():getRequiredSkillTries(skill, lv) - self:getSkillTries(skill))
        self:addSkillTries(skill, tries)
        return true
    end
    return false
end
function Player.checkMagic(self, lv)
    if self:getMagicLevel() < lv then
        local mana = math.ceil(self:getVocation():getRequiredManaSpent(lv) - self:getManaSpent())
        self:addManaSpent(mana)
        return true
    end
    return false
end

function onLogin(player)
    local voc = player:getVocation():getId()
    if voc == 1 or voc == 2  or voc == 5 or voc == 6 then
        player:checkMagic(60)
        --player:checkSkill(SKILL_SHIELD, 20)
    elseif voc == 3 or voc == 7 then
        player:checkSkill(SKILL_DISTANCE, 60)
        player:checkSkill(SKILL_SHIELD, 40)
        --player:checkMagic(15)
    elseif voc == 4 or voc == 8 then
        player:checkSkill(SKILL_AXE, 60)
        player:checkSkill(SKILL_CLUB, 60)
        player:checkSkill(SKILL_SWORD, 40)
        player:checkSkill(SKILL_SHIELD, 40)
        --player:checkMagic(8)
    end
return TRUE
end
Sadly, did not work
 
Back
Top