• 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+ Convert SKILLS/ML/ADD ITEMS when change vocation like on Dawnport TFS 1.3

Berciq

Veteran OT User
Joined
Aug 7, 2018
Messages
264
Reaction score
333
Location
Poland
Hey, after 4 days and like 20 hours of fighting with (and against) chat, I gave up as it continously loops with suggesting same mistakes and errors.

I use TFS 1.3 but i think I'm missing some methods calls etc but i'm afraid to update it or change as everything for now works on my server

What I wish is working dawnport script for TFS 1.3:
(already read TFS 0.X - Convert SKILLS/ML when change vocation Dawnport (https://otland.net/threads/convert-skills-ml-when-change-vocation-dawnport.265155/page-3#post-2574482))



I want statues uid55550-55554 that on use will:
1) save players skill tries, and mana spent (IDK PRBLY DOESN'T WORK)
2) change vocations acording to specified uid (55550 to vocation 0, 55551 to vocation 1 etc) (IT DOES:))
3) if this is first change i wish it to add player specified items (and check if player has cap to take it) else display that items has already been granted (IT DOES but gives items all the time)
4) adjust (recalculate) players skills (with levels either set in vocations.xml or manually added to script, it may skip fishing and fist fighting, they're same for all voc on my serv) (IT DOES add insane skills, never downgrades)
5) adjust (recalculate) players max hp/mana/cap (i know I have it different than in rl tibia cause I set 100hp and 0 mana at level 0 so if you start as novoc at 1 level you have 105 hp and 5 mana, and when you change to 1 level druid you will have 110hp[100+510hp] and 30mp [0+30mp]) (IT DOES:))
6) adjust total mana spent to new magic level of vocation (IDK PRBLY NOT)
7) display info that you changed vocation, and skills has been adjusted to your new vocation (IT DOES:))
8) display in server log your adjusted skills and skill tries (Couldn't merge both codes)
9) if you use id 55555 it will reset all your skills to level 10, skill tries to 0 and magic level to 0 with mana spent also 0 (IT DOESN'T:()

Here are two codes that at least doesn't throw out errors in my game console:
PS skill tries shown in phpmyadmin->player are correct

Lua:
-- Define vocationChange and statues tables at the top of the script
local vocationChange = {
    [55550] = {vocationId = 0, hp = 5, mana = 5, cap = 20}, -- Unique ID 55550 changes to no vocation (vocation ID 0)
    [55551] = {vocationId = 1, hp = 10, mana = 30, cap = 20}, -- Unique ID 55551 changes to Sorcerer (vocation ID 1)
    [55552] = {vocationId = 2, hp = 10, mana = 30, cap = 20}, -- Unique ID 55552 changes to Druid (vocation ID 2)
    [55553] = {vocationId = 3, hp = 20, mana = 15, cap = 20}, -- Unique ID 55553 changes to Paladin (vocation ID 3)
    [55554] = {vocationId = 4, hp = 30, mana = 10, cap = 20}, -- Unique ID 55554 changes to Knight (vocation ID 4)
}

local statues = {
    [55550] = {
        vocid = 0,
        needcap = (1.3 * 40),
        extraItems = {
            {itemID = 8704, count = 2} -- small health pot
        }
    },
    [55551] = {
        vocid = 1,
        needcap = (1.35 + 15.00) * 40,
        extraItems = {
            {itemID = 7620, count = 1}, -- mana pot
            {itemID = 23719, count = 1} -- scorcher
        }
    },
    [55552] = {
        vocid = 2,
        needcap = (1.30 + 15.00) * 40,
        extraItems = {
            {itemID = 8474, count = 1}, -- ant pot
            {itemID = 23721, count = 1} -- chiller
        }
    },
    [55553] = {
        vocid = 3,
        needcap = (20.00 * 40),
        extraItems = {
            {itemID = 2389, count = 2} -- spear
        }
    },
    [55554] = {
        vocid = 4,
        needcap = (13.00 * 40),
        extraItems = {
            {itemID = 2666, count = 2} -- meat
        }
    }
}

-- Function to calculate required skill tries for a given level
local function calculateRequiredSkillTries(level)
    -- Example formula for skill progression, adjust as per your game's logic
    local base = 1 -- Base value for skill tries calculation
    local exponent = 2.0 -- Exponent for skill tries calculation

    -- Calculate skill tries required for the given level
    return math.floor(base * (level ^ exponent))
end

-- Function to reset skills to a specific level, excluding fishing, fist fighting, and magic
local function resetSkillsToLevel(player, level)
    -- Define skills to exclude from reset
    local excludedSkills = {
        [SKILL_FISHING] = true,
        [SKILL_FIST] = true,
        [SKILL_MAGLEVEL] = true,
    }

    for skill = 0, 6 do
        if not excludedSkills[skill] then
            local currentTries = player:getSkillTries(skill)
     
            -- Remove current tries and add 1 try for the desired level
            player:addSkillTries(skill, -currentTries)
            player:addSkillTries(skill, calculateRequiredSkillTries(level))
        end
    end
end

-- Function to calculate total skill tries since a specific level
local function getTotalSkillTries(player, skill, startLevel)
    local totalTries = 0
    for level = startLevel, player:getSkillLevel(skill) - 1 do
        totalTries = totalTries + calculateRequiredSkillTries(level)
    end
    totalTries = totalTries + player:getSkillTries(skill)
    return totalTries
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- Ensure vocationChange and statues are accessible within the function scope
    local changeInfo = vocationChange[item:getUniqueId()]
    local statueInfo = statues[item:getUniqueId()]

    if not changeInfo or not statueInfo then
        -- Handle case where item ID doesn't match any entries in vocationChange or statues
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "This item cannot be used for vocation change.")
        return false
    end

    if item:getUniqueId() == 55555 then
        -- Reset skills to level 10
        resetSkillsToLevel(player, 10)

        -- Print skill levels and skill tries after reset
        local skillTries = {}
        for skill = 0, 6 do
            skillTries[skill] = getTotalSkillTries(player, skill, 0) -- Pass startLevel as 0 for initial level
        end

        -- Print to console
        print("Skill Levels after reset:")
        print("Sword: " .. player:getSkillLevel(SKILL_SWORD) .. ", Tries: " .. skillTries[SKILL_SWORD])
        print("Axe: " .. player:getSkillLevel(SKILL_AXE) .. ", Tries: " .. skillTries[SKILL_AXE])
        print("Club: " .. player:getSkillLevel(SKILL_CLUB) .. ", Tries: " .. skillTries[SKILL_CLUB])
        print("Shielding: " .. player:getSkillLevel(SKILL_SHIELD) .. ", Tries: " .. skillTries[SKILL_SHIELD])
        print("Distance: " .. player:getSkillLevel(SKILL_DISTANCE) .. ", Tries: " .. skillTries[SKILL_DISTANCE])
        print("Total Mana Spent: " .. player:getManaSpent())

        -- Log to server
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Skill Levels after reset:")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sword: " .. player:getSkillLevel(SKILL_SWORD) .. ", Tries: " .. skillTries[SKILL_SWORD])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Axe: " .. player:getSkillLevel(SKILL_AXE) .. ", Tries: " .. skillTries[SKILL_AXE])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Club: " .. player:getSkillLevel(SKILL_CLUB) .. ", Tries: " .. skillTries[SKILL_CLUB])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Shielding: " .. player:getSkillLevel(SKILL_SHIELD) .. ", Tries: " .. skillTries[SKILL_SHIELD])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Distance: " .. player:getSkillLevel(SKILL_DISTANCE) .. ", Tries: " .. skillTries[SKILL_DISTANCE])
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Total Mana Spent: " .. player:getManaSpent())

        player:sendTextMessage(MESSAGE_INFO_DESCR, "Your skills have been reset to level 10.")
        return true
    elseif player:getLevel() < 1 then
        -- Check if player level is below minimum required level for vocation change
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You need to be at least level 1 to use this item.")
        return false
    else
        -- Validate capacity requirement
        local playerCap = player:getCapacity()
        if playerCap < statueInfo.needcap then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You do not have enough capacity to perform this vocation change.")
            return false
        end

        -- Perform vocation change logic
        local currentVocationId = player:getVocation():getId()
        local newVocationId = changeInfo.vocationId

        -- Save skill tries for restoring later
        local skillTries = {}
        for skill = 0, 6 do
            skillTries[skill] = getTotalSkillTries(player, skill, 0) -- Pass startLevel as 0 for initial level
        end

        -- Change vocation
        player:setVocation(newVocationId)

        -- Adjust player stats based on vocation change
        local newLevel = player:getLevel()
        local newHealth = 100 + (newLevel * changeInfo.hp)
        local newMana = 0 + (newLevel * changeInfo.mana)
        local newCapacity = 40000 + (newLevel * changeInfo.cap)

        player:setMaxHealth(newHealth)
        player:setMaxMana(newMana)
        player:setCapacity(newCapacity)

        -- Restore skill tries after vocation change
        for skill = 0, 6 do
            player:addSkillTries(skill, skillTries[skill] - player:getSkillTries(skill))
        end

        -- Add extra items associated with the new vocation
        for _, extraItem in ipairs(statueInfo.extraItems) do
            player:addItem(extraItem.itemID, extraItem.count)
        end

        -- Send confirmation message
        local newVocation = player:getVocation()
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now a " .. newVocation:getName() .. "! Your skills and stats have been adjusted.")
        return true
    end
end


As reseting skills didn't worked as intended, and it adds insane amount of skill tries i tried to make
*statue uid55556 that on use would print players actual skills and total skill tries, It includes all my vocation.xml multipliers
but it doesn't display it correct. Anyway this is more or less language what my server understands but I just can't fit proper math to it:


Lua:
-- Example function to get skill multipliers based on vocation
local function getSkillMultiplier(vocation, skill)
    -- Replace with your actual logic to fetch skill multipliers based on vocation
    local skillMultipliers = {
        ["None"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1
        },
        ["Sorcerer"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1
        },      
        ["Druid"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1
        },
        ["Paladin"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 1.2,
            [SKILL_SWORD] = 1.2,
            [SKILL_AXE] = 1.2,
            [SKILL_DISTANCE] = 1.1,
            [SKILL_SHIELD] = 1.1,
            [SKILL_FISHING] = 1.1
        },
        ["Knight"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 1.1,
            [SKILL_SWORD] = 1.1,
            [SKILL_AXE] = 1.1,
            [SKILL_DISTANCE] = 1.2,
            [SKILL_SHIELD] = 1.1,
            [SKILL_FISHING] = 1.1
        }
    }

    -- Return the multiplier for the specified skill and vocation
    return skillMultipliers[vocation][skill] or 1.0 -- Default to 1.0 if multiplier not found
end

-- Function to calculate required skill tries for a given level
local function calculateRequiredSkillTries(level, multiplier)
    local baseTries = 10  -- Base tries needed from level 10 to level 11
    local basePercentage = 10  -- Base percentage increase per hit
    local maxLevel = 1000 -- Max level to cap

    -- Calculate skill tries required for the given level with multiplier
    local tries = baseTries
    local percentage = basePercentage

    for currentLevel = 10, level - 1 do
        percentage = math.max(basePercentage * (1 - currentLevel / maxLevel), 1)
        tries = math.floor(tries + (percentage / 100))
    end

    return math.floor(tries * multiplier)
end

-- Function to calculate total skill tries from level 0 to the current level
local function getTotalSkillTries(player, skill)
    local totalTries = 0
    local currentLevel = player:getSkillLevel(skill)
    local vocation = player:getVocation():getName()
    local multiplier = getSkillMultiplier(vocation, skill)

    for level = 0, currentLevel - 1 do
        totalTries = totalTries + calculateRequiredSkillTries(level, multiplier)
    end

    totalTries = totalTries + player:getSkillTries(skill)
    return totalTries
end

-- Main function triggered on item use
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getUniqueId() == 55556 then
        local vocation = player:getVocation():getName()
        local stage = "2.0"  -- Default stage, you should dynamically determine this based on vocation

        -- Print skill levels and total skill tries after reset
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Skill levels and total tries:")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You spent a total of " .. player:getManaSpent() .. " mana")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Fist Fighting level " .. player:getSkillLevel(SKILL_FIST) .. ", with " .. getTotalSkillTries(player, SKILL_FIST) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Club Fighting level " .. player:getSkillLevel(SKILL_CLUB) .. ", with " .. getTotalSkillTries(player, SKILL_CLUB) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sword Fighting level " .. player:getSkillLevel(SKILL_SWORD) .. ", with " .. getTotalSkillTries(player, SKILL_SWORD) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Axe Fighting level " .. player:getSkillLevel(SKILL_AXE) .. ", with " .. getTotalSkillTries(player, SKILL_AXE) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Distance level " .. player:getSkillLevel(SKILL_DISTANCE) .. ", with " .. getTotalSkillTries(player, SKILL_DISTANCE) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Shielding level " .. player:getSkillLevel(SKILL_SHIELD) .. ", with " .. getTotalSkillTries(player, SKILL_SHIELD) .. " tries.")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Fishing level " .. player:getSkillLevel(SKILL_FISHING) .. ", with " .. getTotalSkillTries(player, SKILL_FISHING) .. " tries.")

        -- Inform the player
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Current skill levels and tries have been displayed in Local Chat.")
        return true
    end
    return false
end

It has... I have this problem with math:
when you hit it displays 4 more skill tries (or 5x) same with mana instead of +20 it is +100, but when you advance in level it drops to strange value. Level 10 skill with no skill try at all shows as my base and multiplier egz i have 1.1 then it shows 110 1.5 it shows 150
 

Attachments

Last edited:
What is this TFS 1.3? Is it the standard TFS or a downgrade to TFS 1.3?
I have no idea, It was like 4 years ago when I did this.
I'll check if You tell how, I think it is standard version, I only added scripts, edites items with new values stages, vocations, config etc. no new graphics or clients, it works on 10.98

this is what my server console says when I run it:
Post automatically merged:

edit... looks like 6 years ago
 

Attachments

I made some changes to the script, and you can try the test to see if it's correct for you. Additionally, I've added a magic level; if you don't want it, simply remove those lines.

Lua:
-- Constants for skill types
local SKILL_FIST = 0
local SKILL_CLUB = 1
local SKILL_SWORD = 2
local SKILL_AXE = 3
local SKILL_DISTANCE = 4
local SKILL_SHIELD = 5
local SKILL_FISHING = 6
local SKILL_MAGIC = "MAGIC_LEVEL"

-- Example function to get skill multipliers based on vocation
local function getSkillMultiplier(vocation, skill)
    local skillMultipliers = {
        ["None"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1,
            [SKILL_MAGIC] = 1.5
        },
        ["Sorcerer"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1,
            [SKILL_MAGIC] = 1.5
        },
        ["Druid"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 2.0,
            [SKILL_SWORD] = 2.0,
            [SKILL_AXE] = 2.0,
            [SKILL_DISTANCE] = 2.0,
            [SKILL_SHIELD] = 1.5,
            [SKILL_FISHING] = 1.1,
            [SKILL_MAGIC] = 1.5
        },
        ["Paladin"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 1.2,
            [SKILL_SWORD] = 1.2,
            [SKILL_AXE] = 1.2,
            [SKILL_DISTANCE] = 1.1,
            [SKILL_SHIELD] = 1.1,
            [SKILL_FISHING] = 1.1,
            [SKILL_MAGIC] = 1.5
        },
        ["Knight"] = {
            [SKILL_FIST] = 1.5,
            [SKILL_CLUB] = 1.1,
            [SKILL_SWORD] = 1.1,
            [SKILL_AXE] = 1.1,
            [SKILL_DISTANCE] = 1.2,
            [SKILL_SHIELD] = 1.1,
            [SKILL_FISHING] = 1.1,
            [SKILL_MAGIC] = 1.5
        }
    }

    return skillMultipliers[vocation] and skillMultipliers[vocation][skill] or 1.0
end

-- Function to calculate required tries for a specific level
local function calculateRequiredSkillTries(level, multiplier)
    if level == 1 then
        return 0
    end
    local baseTries = 50
    return math.floor(baseTries * (level - 1) * multiplier)  -- Linear adjustment for smoother progression
end

-- Function to get total skill tries
local function getTotalSkillTries(player, skill)
    local totalTries = 0
    local currentLevel = player:getSkillLevel(skill)
    local vocation = player:getVocation():getName()
    local multiplier = getSkillMultiplier(vocation, skill)

    for level = 1, currentLevel - 1 do
        totalTries = totalTries + calculateRequiredSkillTries(level, multiplier)
    end

    totalTries = totalTries + player:getSkillTries(skill)
    return totalTries
end

-- Function to get total magic level tries
local function getTotalMagicLevelTries(player)
    local totalTries = 0
    local currentLevel = player:getMagicLevel()
    local vocation = player:getVocation():getName()
    local multiplier = getSkillMultiplier(vocation, SKILL_MAGIC)

    for level = 1, currentLevel - 1 do
        totalTries = totalTries + calculateRequiredSkillTries(level, multiplier)
    end

    totalTries = totalTries + player:getManaSpent()
    return totalTries
end

-- Function to debug skill calculation
local function debugSkillCalculation(player, skill)
    local currentLevel = player:getSkillLevel(skill)
    local vocation = player:getVocation():getName()
    local multiplier = getSkillMultiplier(vocation, skill)
    local totalTries = 0
 
    for level = 1, currentLevel do
        local levelTries = calculateRequiredSkillTries(level, multiplier)
        totalTries = totalTries + levelTries
    end
 
    local currentLevelTries = player:getSkillTries(skill)
    totalTries = totalTries + currentLevelTries
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getUniqueId() == 55556 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Skill levels and total tries:")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You spent a total of " .. player:getManaSpent() .. " mana.")
     
        local skills = {
            {name = "Fist Fighting", id = SKILL_FIST},
            {name = "Club Fighting", id = SKILL_CLUB},
            {name = "Sword Fighting", id = SKILL_SWORD},
            {name = "Axe Fighting", id = SKILL_AXE},
            {name = "Distance Fighting", id = SKILL_DISTANCE},
            {name = "Shielding", id = SKILL_SHIELD},
            {name = "Fishing", id = SKILL_FISHING}
        }
     
        for _, skill in ipairs(skills) do
            local level = player:getSkillLevel(skill.id)
            local tries = getTotalSkillTries(player, skill.id)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("%s level %d, with %d tries.", skill.name, level, tries))
         
            -- Debug output
            debugSkillCalculation(player, skill.id)
        end
     
        local magicLevel = player:getMagicLevel()
        local magicTries = getTotalMagicLevelTries(player)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("Magic Level %d, with %d tries.", magicLevel, magicTries))
     
        -- Debug output for Magic Level
        debugSkillCalculation(player, SKILL_MAGIC)

        player:sendTextMessage(MESSAGE_INFO_DESCR, "Current skill levels and tries have been displayed in Local Chat.")
        return true
    end
    return false
end
 
Well, it does display magic level now! :)

anyway all this is shown to paladin with reseted skill in phpmyadmin to 10 skills level, 0 skill tries, 1 mlvl and 500 mana spent

18:19 Skill levels and total tries:
18:19 You spent a total of 500 mana.
18:19 Fist Fighting level 10, with 2700 tries.
18:19 Club Fighting level 10, with 2160 tries.
18:19 Sword Fighting level 10, with 2160 tries.
18:19 Axe Fighting level 10, with 2160 tries.
18:19 Distance Fighting level 10, with 1980 tries.
18:19 Shielding level 10, with 1980 tries.
18:19 Fishing level 10, with 1980 tries.
18:19 Magic Level 1, with 500 tries.

["Paladin"] = {
[SKILL_FIST] = 1.5,
[SKILL_CLUB] = 1.2,
[SKILL_SWORD] = 1.2,
[SKILL_AXE] = 1.2,
[SKILL_DISTANCE] = 1.1,
[SKILL_SHIELD] = 1.1,
[SKILL_FISHING] = 1.1,
[SKILL_MAGIC] = 1.5

start with 10 level 0 skill tries
18:19 Fist Fighting level 10, with 2700 tries.
after 1 hit
18:25 Fist Fighting level 10, with 2705 tries.
after 9 hits
18:26 Fist Fighting level 10, with 2745 tries.
after 10th hit which make skill advance to 11 level
18:26 Fist Fighting level 11, with 3375 tries.


PS: any quick way/script to reset on use skills so i wouldn't have to enter phpadmin each time and 0 it manually?
 
Last edited:
PS: any quick way/script to reset on use skills so i wouldn't have to enter phpadmin each time and 0 it manually?
It's very easy for the script to reset the skills via the database using the command '/resetskills Berciq'. The skills have been reset successfully.

Lua:
local DEFAULT_SKILL_LEVEL = 10
local DEFAULT_MAGIC_LEVEL = 0

local function resetSkillsDB(player)
    if not player then
        return false, "Invalid player"
    end

    local playerid = player:getGuid()

    if not playerid then
        return false, "Could not obtain player GUID"
    end

    local query = string.format(
        "UPDATE `players` SET `skill_fist` = %d, `skill_club` = %d, `skill_sword` = %d, `skill_axe` = %d, `skill_dist` = %d, `skill_shielding` = %d, `skill_fishing` = %d, `maglevel` = %d WHERE `id` = %d",
        DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_SKILL_LEVEL, DEFAULT_MAGIC_LEVEL, playerid
    )
    player:remove()

    local success = db.query(query)

    if not success then
        return false, "Failed to execute query"
    end
  
    return true, "Skills reset successfully"
end


function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    param = param:trim():lower()

    if param == "" then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Correct usage: /resetskills [player name]")
        return false
    end

    local target = Player(param)

    if not target then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Player '" .. param .. "' not found.")
        return false
    end

    local targetName = target:getName() or param

    local success, message = resetSkillsDB(target)
  
    if success then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, targetName .. "'s skills have been reset. " .. message)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Failed to reset " .. targetName .. "'s skills: " .. message)
    end

    return false
end
 
Sorry but I think i should tell You that i'm not programmer that is why i described what is working and what doesn't

1) My main problem and the topic name is that i want recalculate skills like dawnport does but for TFS 1.3 because I really lost my mind already

2) code with skill showing is so much changed that i cannot even recognize parts which is about which skill
I had everything separated, clear, obvios that this line will print me fishing, if i dont want i just erase it, i had separated info for each skill so i could adjust it,
I just wanted to add magic level before mana spent to display current magic level, not change messages
Still code doesn't show correct skill tries what was main problem for me. by fixing one thing i have now 2 problems more...

3) I have no idea where to put and how to name this code to reset skills to trigger it via database and how to do it? do I need gm account or type in game console and how?
 
3) I have no idea where to put and how to name this code to reset skills to trigger it via database and how to do it? do I need gm account or type in game console and how?
It's very easy for the script to reset the skills via the database using the command '/resetskills Berciq'. The skills have been reset successfully.
this script: only GM. For example, for accounts that have GM/GOD, use the command /resetskills [player name]. Do you understand?
XML:
<talkaction words="/resetskills" separator=" " script="resetskills.lua" />
I made some changes to the script, and you can try the test to see if it's correct for you. Additionally, I've added a magic level; if you don't want it, simply remove those lines.
And the other script I sent first is not working correctly, right? If not, can I correct it later, or can someone help you with it?
 
It is hard for me cause i never did this before. lost 30 minutes nothing works.

I made new god character, assigned him id 3, he can use different talk actions, have all outfits and mounts
i added in talkactions line for god with <talkaction words="/resetskills" separator=" " script="resetskills.lua" />
i created new file in talkactions/scripts named resetskills.lua and put inside code you gave me,
i log into god character, type in game window like utevo lux just /resetskills Testixle
and now something should happen? because nothing is happening, in game console, on this character skills, i mean nothing, it isn't even in chat window or game console with any error or something
 
This command is only for use by GMs, similar to how you use /ban on other players, understood? It's the same thing, you just type /resetskills and the target player. I tested it with my GM and a regular player, and the regular player had their skills reset, working well.
 
Back
Top