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

max level

xLosT

Member
Joined
Jan 11, 2010
Messages
1,022
Reaction score
13
Location
Brasil, Rio Grande do Sul
hi, i have a war server and need set max level i test this script but dont work
tfs 1.2

Code:
local c = {
    savePlayersOnAdvance = true,
    maxLevel = 600
}

function onAdvance(player, skill, oldLevel, newLevel)
    if(config.savePlayersOnAdvance) then
player:save()
    end

    if newLevel >= c.maxLevel and skill == SKILL__LEVEL then
        newLevel = c.maxLevel
    end

    return true
end
 
You probably want to change
Code:
if(config.savePlayersOnAdvance) then
to
Code:
if(c.savePlayersOnAdvance) then
 
you're reassigning a variable, not changing the player's level
ohh sorry, i fumbled
i have this, but not found function remove level on tfs 1.2
Code:
function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL__LEVEL then
        return true
    end
        if newLevel >= 601 then
            doPlayerAddLevel(cid, -1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Max level is 600!')
        end
    return true
end
[code]
 
ohh sorry, i fumbled
i have this, but not found function remove level on tfs 1.2
Code:
function onAdvance(player, skill, oldLevel, newLevel)
    if skill ~= SKILL__LEVEL then
        return true
    end
        if newLevel >= 601 then
            doPlayerAddLevel(cid, -1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Max level is 600!')
        end
    return true
end
[code]
lib/compat/compat.lua
Code:
function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
lib/core/player.lua
Code:
function Player.addLevel(self, lv)
    local exp = getExperienceForLevel(self:getLevel() + lv) - self:getExperience()
    --// Avoid exp overflow
    if (self:getLevel() + lv) >= 717217 then
        exp = getExperienceForLevel(717217) - self:getExperience()
    end
    return self:addExperience(exp)
end

function Player.removeLevel(self, lv)
    local exp = self:getExperience() - getExperienceForLevel(self:getLevel() - lv)
    --// Avoid exp underflow
    if (self:getLevel() - lv) < 2 then
        exp = 0
    end
    return self:removeExperience(exp)
end

you're also using 0.4 functions with cid in tfs 1.2 when you don't even have cid in the function arguments
 
Back
Top