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

addskill for levels does not work above 71k levels tfs 1.3

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,821
Solutions
82
Reaction score
1,943
Location
Germany
yooo
as the title says
addskill for levels does not work after 71k levels
how comes?
tfs 1.3
addskill lua
Lua:
local function getSkillId(skillName)
    if skillName == "club" then
        return SKILL_CLUB
    elseif skillName == "sword" then
        return SKILL_SWORD
    elseif skillName == "axe" then
        return SKILL_AXE
    elseif skillName:sub(1, 4) == "dist" then
        return SKILL_DISTANCE
    elseif skillName:sub(1, 6) == "shield" then
        return SKILL_SHIELD
    elseif skillName:sub(1, 4) == "fish" then
        return SKILL_FISHING
    else
        return SKILL_FIST
    end
end

local function getExpForLevel(level)
    level = level - 1
    return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
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

    local split = param:splitTrimmed(",")
    if not split[2] then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if not target then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end

    local count = 1
    if split[3] then
        count = tonumber(split[3])
    end

    local ch = split[2]:sub(1, 1)
    for i = 1, count do
        if ch == "l" or ch == "e" then
            target:addExperience(getExpForLevel(target:getLevel() + 1) - target:getExperience(), false)
        elseif ch == "m" then
            target:addManaSpent(target:getVocation():getRequiredManaSpent(target:getBaseMagicLevel() + 1) - target:getManaSpent())
        else
            local skillId = getSkillId(split[2])
            target:addSkillTries(skillId, target:getVocation():getRequiredSkillTries(skillId, target:getSkillLevel(skillId) + 1) - target:getSkillTries(skillId))
        end
    end
    return false
end
 
Solution
u need to change int LuaScriptInterface::luaPlayerAddExperience(lua_State* L)
change experience from int64_t to uint64_t, result: uint64_t experience = getNumber<uint64_t>(L, 2);

and u can add a bit of extra xp (i add 10k) when it calculates 0 because the calculation isnt precise so its sort of "rounded" (not really but thats kinda how the result of the calc is)
so sometimes when u add itll be +1 or -1 level every now and then but it works good enough to add like 100k+ lvls and shit
Lua:
local function getSkillId(skillName)
    if skillName == "club" then
        return SKILL_CLUB
    elseif skillName == "sword" then
        return SKILL_SWORD
    elseif skillName == "axe" then
        return SKILL_AXE
    elseif skillName:sub(1...
u need to change int LuaScriptInterface::luaPlayerAddExperience(lua_State* L)
change experience from int64_t to uint64_t, result: uint64_t experience = getNumber<uint64_t>(L, 2);

and u can add a bit of extra xp (i add 10k) when it calculates 0 because the calculation isnt precise so its sort of "rounded" (not really but thats kinda how the result of the calc is)
so sometimes when u add itll be +1 or -1 level every now and then but it works good enough to add like 100k+ lvls and shit
Lua:
local function getSkillId(skillName)
    if skillName == "club" then
        return SKILL_CLUB
    elseif skillName == "sword" then
        return SKILL_SWORD
    elseif skillName == "axe" then
        return SKILL_AXE
    elseif skillName:sub(1, 4) == "dist" then
        return SKILL_DISTANCE
    elseif skillName:sub(1, 6) == "shield" then
        return SKILL_SHIELD
    elseif skillName:sub(1, 4) == "fish" then
        return SKILL_FISHING
    else
        return SKILL_FIST
    end
end

function getExpForLevel(level)
    level = level - 1
    return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
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

    local split = param:splitTrimmed(",")
    if not split[2] then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if not target then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end

    local count = 1
    if split[3] then
        count = tonumber(split[3])
    end

    local ch = split[2]:sub(1, 1)
    for i = 1, count do
        if ch == "l" or ch == "e" then
            if getExpForLevel(target:getLevel() + 1) - target:getExperience() == 0 then
                target:addExperience(10000)
            end
            target:addExperience(getExpForLevel(target:getLevel() + 1) - target:getExperience(), false)
        elseif ch == "m" then
            target:addManaSpent(target:getVocation():getRequiredManaSpent(target:getBaseMagicLevel() + 1) - target:getManaSpent())
        else
            local skillId = getSkillId(split[2])
            target:addSkillTries(skillId, target:getVocation():getRequiredSkillTries(skillId, target:getSkillLevel(skillId) + 1) - target:getSkillTries(skillId))
        end
    end
    return false
end
 
Solution
u need to change int LuaScriptInterface::luaPlayerAddExperience(lua_State* L)
change experience from int64_t to uint64_t, result: uint64_t experience = getNumber<uint64_t>(L, 2);

and u can add a bit of extra xp (i add 10k) when it calculates 0 because the calculation isnt precise so its sort of "rounded" (not really but thats kinda how the result of the calc is)
so sometimes when u add itll be +1 or -1 level every now and then but it works good enough to add like 100k+ lvls and shit
Lua:
local function getSkillId(skillName)
    if skillName == "club" then
        return SKILL_CLUB
    elseif skillName == "sword" then
        return SKILL_SWORD
    elseif skillName == "axe" then
        return SKILL_AXE
    elseif skillName:sub(1, 4) == "dist" then
        return SKILL_DISTANCE
    elseif skillName:sub(1, 6) == "shield" then
        return SKILL_SHIELD
    elseif skillName:sub(1, 4) == "fish" then
        return SKILL_FISHING
    else
        return SKILL_FIST
    end
end

function getExpForLevel(level)
    level = level - 1
    return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
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

    local split = param:splitTrimmed(",")
    if not split[2] then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end

    local target = Player(split[1])
    if not target then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end

    local count = 1
    if split[3] then
        count = tonumber(split[3])
    end

    local ch = split[2]:sub(1, 1)
    for i = 1, count do
        if ch == "l" or ch == "e" then
            if getExpForLevel(target:getLevel() + 1) - target:getExperience() == 0 then
                target:addExperience(10000)
            end
            target:addExperience(getExpForLevel(target:getLevel() + 1) - target:getExperience(), false)
        elseif ch == "m" then
            target:addManaSpent(target:getVocation():getRequiredManaSpent(target:getBaseMagicLevel() + 1) - target:getManaSpent())
        else
            local skillId = getSkillId(split[2])
            target:addSkillTries(skillId, target:getVocation():getRequiredSkillTries(skillId, target:getSkillLevel(skillId) + 1) - target:getSkillTries(skillId))
        end
    end
    return false
end

Thanks for the help
have a nice day :D
 
Back
Top