• 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+ Problem with adding lvl. TFS 1.5 8.6

kikol

New Member
Joined
May 3, 2019
Messages
20
Reaction score
0
Hello, I have a problem with TFS 1.5. After compiling and running, when I add a level, for example with /addskill, or after using an item that is supposed to add 3 levels, it adds more than it should. How can I fix this?
 
show code
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
    elseif skillName:sub(1, 4) == "fist" then
        return SKILL_FIST
    elseif skillName:sub(1, 1) == "m" then
        return SKILL_MAGLEVEL
    elseif skillName == "level" or skillName:sub(1, 1) == "l" or skillName:sub(1, 1) == "e" then
        return SKILL_LEVEL
    end

    return nil
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 skillId = getSkillId(split[2])
    if not skillId then
        player:sendCancelMessage("Unknown skill.")
        return false
    end

    target:addSkill(skillId, count)
    return false
end
expitem.lua
LUA:
local stages = {
    {8, -1, {1, 3}}
}

function onUse(player, item, fromPosition, target, toPosition)
    if player:getLevel() >= 8 then
        if player:getStorageValue(1803) == 2 then
            player:say("You have already used that!", TALKTYPE_MONSTER_SAY)
        else
            for v,k in pairs(stages) do
                if k[2] == -1 and player:getLevel() >= k[1] then
                    local t = math.random(k[3][1], k[3][2])
                    player:addLevel(t)
                    player:say("Added " .. t .. " levels.", TALKTYPE_MONSTER_SAY)
                    break
                elseif player:getLevel() >= k[1] and player:getLevel() <= k[2] then
                    player:addLevel(k[3])
                    player:say("Added " .. k[3] .. " levels.", TALKTYPE_MONSTER_SAY)
                    break
                end
            end
            fromPosition:sendMagicEffect(CONST_ME_GIFT_WRAPS)
            item:remove()
            player:setStorageValue(1800, 2)
            return true
        end
    else
        player:say("Your level is lower than 8.", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(1800, 2)
        return true
    end
end
 
You are adding a table and not a single number. I am not sure why you don't use math.random(1,3) instead and for k[3] just a number.
So addlevel(3) for example.
 
tfs 1.5 I use this
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
    elseif skillName:sub(1, 4) == "fist" then
        return SKILL_FIST
    elseif skillName:sub(1, 1) == "m" then
        return SKILL_MAGLEVEL
    elseif skillName == "level" or skillName:sub(1, 1) == "l" or skillName:sub(1, 1) == "e" then
        return SKILL_LEVEL
    end

    return nil
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 skillId = getSkillId(split[2])
    if not skillId then
        player:sendCancelMessage("Unknown skill.")
        return false
    end

    target:addSkill(skillId, count)
    return false
end
 
Hello, I have a problem with TFS 1.5. After compiling and running, when I add a level, for example with /addskill, or after using an item that is supposed to add 3 levels, it adds more than it should. How can I fix this?
I think it's the experiencestages in config.lua
 
Back
Top