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

C++ XP Gain Rate + Bonus XP

Lais Prad

Disgusting Scammer
Joined
Apr 12, 2017
Messages
153
Solutions
6
Reaction score
15
How to add in this config to show in skill stats?

player.lua
Lua:
local BONUS_EXP_STORAGE = 61398
    local BONUS_EXP_MULT = 1.2

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

    -- 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
        -- I WANT TO ADD THIS BONUS FOR SHOW IN STATS
    if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
    exp = exp * BONUS_EXP_MULT -- 20%

    end

    return exp
end

I tried this way:
C++:
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0
{
msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*120); // base xp gain rate
}
else
    {
        msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100); // base xp gain rate
    }

protocolgame.base
C++:
msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100); // base xp gain rate
    msg.add<uint16_t>(player->getVoucherXpBoost()); // xp voucher
     msg.add<uint16_t>(player->getGrindingXpBoost()); // low level bonus
     msg.add<uint16_t>(player->getStoreXpBoost()); // xp boost
     msg.add<uint16_t>(player->getStaminaXpBoost()); // stamina multiplier (100 = 1.0x)
 
Solution
You are using Lua functions in a C++ code, thats the problem.
You use;
C++:
player->getStorageValue(key) - OTSYS_TIME() > 0

And im pretty sure you can't send this;
C++:
g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100

It is most likely gonna send the percentage, ex if you have a 20% boost it should send 20.
I'll try, thanks.

You are using Lua functions in a C++ code, thats the problem.
You use;
C++:
player->getStorageValue(key) - OTSYS_TIME() > 0

And im pretty sure you can't send this;
C++:
g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100

It is most likely gonna send the percentage, ex if you have a 20% boost it should send 20.

How can I code this correctly?

C++:
if (player->getStorageValue(61398) -...
You are using Lua functions in a C++ code, thats the problem.
You use;
C++:
player->getStorageValue(key) - OTSYS_TIME() > 0

And im pretty sure you can't send this;
C++:
g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100

It is most likely gonna send the percentage, ex if you have a 20% boost it should send 20.
 
You are using Lua functions in a C++ code, thats the problem.
You use;
C++:
player->getStorageValue(key) - OTSYS_TIME() > 0

And im pretty sure you can't send this;
C++:
g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100

It is most likely gonna send the percentage, ex if you have a 20% boost it should send 20.
I'll try, thanks.

You are using Lua functions in a C++ code, thats the problem.
You use;
C++:
player->getStorageValue(key) - OTSYS_TIME() > 0

And im pretty sure you can't send this;
C++:
g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100

It is most likely gonna send the percentage, ex if you have a 20% boost it should send 20.

How can I code this correctly?

C++:
if (player->getStorageValue(61398) - OTSYS_TIME() > 0) {
    msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*120); // base xp gain rate
        }
    else {
    msg.add<uint16_t>(g_config.getNumber(ConfigManager::RATE_EXPERIENCE)*100); // base xp gain rate
        }
 
Last edited by a moderator:
Solution
Please read the rules; Rules for the Support board
#2

As I said I don't know what the uint_16_t values should send, you have to check that first.
And clean the code abit, if the player has the storage value and you send the correct value it should work.
 
Back
Top