• 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 Exp extra for players vips

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
original
Code:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end

edited
Code:
 function Player:onGainExperience(source, exp, rawExp)
   if not source or source:isPlayer() then

if self:isVip() then
       local exp_extra = 1.5 -- 50% +
       exp = exp * exp_extra
   end
       return exp
   end

My vip
Code:
-- player:isVip()
function Player.isVip(self)
    return self:getVipTime() > os.time() and true or false
end

I made this edition for vip players, I get 50% more exp. It did not work. I did not have any errors in the console.
 
Solution
Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if self:isVip() then
        exp = exp * 1.5
    end
    return exp
end
Try this
Code:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        if source:getPremiumDays() > 0 then
            exp = exp * 1.5
        end
        return exp
    end
end
 
see what this prints
Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        print(self:isVip())
        if self:isVip() then
            local exp_extra = 1.5 -- 50% +
            exp = exp * exp_extra
        end
    end
    return exp
end
 
see what this prints
Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        print(self:isVip())
        if self:isVip() then
            local exp_extra = 1.5 -- 50% +
            exp = exp * exp_extra
        end
    end
    return exp
end
[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:1056: <eof> expected near 'end'

I removed the end of the error but did not increase the exp gain
I tested it with the other function but it did not work Player.getVipTime(cid) > 0
exp gain in game is 200% would have to be 250%
more continuous 200%
 
Last edited:
Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if self:isVip() then
        exp = exp * 1.5
    end
    return exp
end
 
Solution
Lua:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if self:isVip() then
        exp = exp * 1.5
    end
    return exp
end
[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:1054: <eof> expected near 'end'
 
you're copy/pasting something wrong or you have remnants of the old onGainExperience function inside of your file.
you have too many ends
 
Remove these two lines: player.lua · GitHub
can somebody tell me what lines do I have to remove, it doesnt work with tfs 1.5 downgraded 8.6 by nekiro

Edit: Already solved it, if anyone want it, you just have to edit player.lua and let this function like this:
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

    if self:isVip() then
    exp = exp * 1.5
    end

    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

    -- 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 hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
end
 
Last edited:
can somebody tell me what lines do I have to remove, it doesnt work with tfs 1.5 downgraded 8.6 by nekiro

Edit: Already solved it, if anyone want it, you just have to edit player.lua and let this function like this:
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

    if self:isVip() then
    exp = exp * 1.5
    end

    -- Apply experience stage multiplier
    exp = exp * Game.getExperienceStage(self:getLevel())

    -- 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 hasEventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE) and EventCallback(EVENT_CALLBACK_ONGAINEXPERIENCE, self, source, exp, rawExp) or exp
end
Thanks, i have been struggling for a while with this :D
 
Back
Top