• 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 Whats wrong with this script?

cristianso

Member
Joined
Jan 27, 2019
Messages
47
Reaction score
16
I made a EXP script that forces the player to get a certain amount of exp in rookgaard and when he moves to main island he get the normal exp. The script is working until level 20, after that it is like I am playing 1x server... Whats going on?

PS: I am sure I disabled Stages in XML.

This code is inside events\scripts\player.lua,

Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

    -- Soul regeneration
    local vocation = self:getVocation()
    if self:getSoul() < vocation:getMaxSoul() and exp >= self:getLevel() then
        soulCondition:setParameter(CONDITION_PARAM_SOULTICKS, vocation:getSoulGainTicks() * 1000)
        self:addCondition(soulCondition)
    end

    local town = self:getTown():getId()
    local level = self:getLevel()
    
    if town <= 2 then
        exp = exp * 2.5
    end
    
    if town > 2 then
        if level <20 then
            exp = exp*12
        end
        if level >=21 and level <60 then
            exp = exp*10
        end
        if level >=61 and level <100 then
            exp = exp*8
        end
        if level >=101 and level <130 then
            exp = exp*6
        end
        if level >=131 and level <160 then
            exp = exp * 4
        end
        if level >= 161 then
            exp = exp*2
        end
    end
    

    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        end
    end

    return exp
end
 
Solution
Yeah that will work. Do the first if, then elseif for the rest, removing the ends. I'm on my phone right now or I would type it up for you.
Not a problem with town, because the script works when I move to town 3, but when I reach level 20 It stop working. And thanks you for your reply!
 
Yeah that will work. Do the first if, then elseif for the rest, removing the ends. I'm on my phone right now or I would type it up for you.
 
Solution
Back
Top