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

Compiling XP Gain Rate (client) TFS 1.2

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
580
Solutions
1
Reaction score
57
vlMWPW2.png


how add in my sources to work exp gain rate?
 
Code:
function onSay(player, words, param)
player:setStoreXpBoost(30)
 return false
end

Works in normal scripts.

I have problems adding it to player.lua

want add this:

Code:
function Player:onGainExperience(source, exp, rawExp)

     if not source or source:isPlayer() then
         return exp
     end
    
     exp = exp * configexp[os.date("%A")]     
    
    -- 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
       self:setStoreXpBoost(50)
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
          self:setStaminaXpBoost(50)
        end
    end

    
   -- exp card
 if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
  exp = exp * BONUS_EXP_MULT
self:setStoreXpBoost(30)
 end
    -- exp card

    return exp
end
 
@Ninja

@beenii did you solved?

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
 
        -- BONUS EXP I WANT TO ADD HERE THE FUNCTION
    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
    }
 
Last edited:
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
    }
This exactly the reason as to why I uploaded the patch in the first place. You shouldn't have to resort to additional source modifications like that when you already got the opportunity to manipulate boost values in Lua.

Available methods:
C++:
registerMethod("Player", "getBaseXpGain", LuaScriptInterface::luaPlayerGetBaseXpGain);
registerMethod("Player", "setBaseXpGain", LuaScriptInterface::luaPlayerSetBaseXpGain);
registerMethod("Player", "getVoucherXpBoost", LuaScriptInterface::luaPlayerGetVoucherXpBoost);
registerMethod("Player", "setVoucherXpBoost", LuaScriptInterface::luaPlayerSetVoucherXpBoost);
registerMethod("Player", "getGrindingXpBoost", LuaScriptInterface::luaPlayerGetGrindingXpBoost);
registerMethod("Player", "setGrindingXpBoost", LuaScriptInterface::luaPlayerSetGrindingXpBoost);
registerMethod("Player", "getStoreXpBoost", LuaScriptInterface::luaPlayerGetStoreXpBoost);
registerMethod("Player", "setStoreXpBoost", LuaScriptInterface::luaPlayerSetStoreXpBoost);
registerMethod("Player", "getStaminaXpBoost", LuaScriptInterface::luaPlayerGetStaminaXpBoost);
registerMethod("Player", "setStaminaXpBoost", LuaScriptInterface::luaPlayerSetStaminaXpBoost);

Here is an example on how to alter the XP Gain Rate value in the skills window:
Lua:
player:setBaseXpGain(300) -- Base XP Gain set to 300% (Base value = 100)
player:setVoucherXpBoost(200) -- Voucher XP Boost set to 200% (Base value = 0)
player:setGrindingXpBoost(200) -- Grinding XP Boost set to 200% (Base value = 0)
player:setStoreXpBoost(200) -- Store XP Boost set to 200% (Base value = 0)
player:setStaminaXpBoost(150) -- Stamina XP Boost set to 50% (Base value = 100)

You will just have to come up with a clever method to implement this to your server (as in updating a certain boost value dependent on a time-based storage value). Good luck! :)
 
This exactly the reason as to why I uploaded the patch in the first place. You shouldn't have to resort to additional source modifications like that when you already got the opportunity to manipulate boost values in Lua.

Available methods:
C++:
registerMethod("Player", "getBaseXpGain", LuaScriptInterface::luaPlayerGetBaseXpGain);
registerMethod("Player", "setBaseXpGain", LuaScriptInterface::luaPlayerSetBaseXpGain);
registerMethod("Player", "getVoucherXpBoost", LuaScriptInterface::luaPlayerGetVoucherXpBoost);
registerMethod("Player", "setVoucherXpBoost", LuaScriptInterface::luaPlayerSetVoucherXpBoost);
registerMethod("Player", "getGrindingXpBoost", LuaScriptInterface::luaPlayerGetGrindingXpBoost);
registerMethod("Player", "setGrindingXpBoost", LuaScriptInterface::luaPlayerSetGrindingXpBoost);
registerMethod("Player", "getStoreXpBoost", LuaScriptInterface::luaPlayerGetStoreXpBoost);
registerMethod("Player", "setStoreXpBoost", LuaScriptInterface::luaPlayerSetStoreXpBoost);
registerMethod("Player", "getStaminaXpBoost", LuaScriptInterface::luaPlayerGetStaminaXpBoost);
registerMethod("Player", "setStaminaXpBoost", LuaScriptInterface::luaPlayerSetStaminaXpBoost);

Here is an example on how to alter the XP Gain Rate value in the skills window:
Lua:
player:setBaseXpGain(300) -- Base XP Gain set to 300% (Base value = 100)
player:setVoucherXpBoost(200) -- Voucher XP Boost set to 200% (Base value = 0)
player:setGrindingXpBoost(200) -- Grinding XP Boost set to 200% (Base value = 0)
player:setStoreXpBoost(200) -- Store XP Boost set to 200% (Base value = 0)
player:setStaminaXpBoost(150) -- Stamina XP Boost set to 50% (Base value = 100)

You will just have to come up with a clever method to implement this to your server (as in updating a certain boost value dependent on a time-based storage value). Good luck! :)

Oops, excuse ignorance, but look what I've tried and dont work here (no error on screen):
player.lua in events

Lua:
if self:getStorageValue(BONUS_EXP_STORAGE) - os.time() > 0 then
    self:setBaseXpGain(130)
    self:setStoreXpBoost(120)
    exp = exp * BONUS_EXP_MULT1
    end
 
Not the best way, but I solved it this way, time ago:
Code:
function onThink(creature, interval)
-- exp card
    if creature:getStorageValue(61398) - os.time() > 0 then
    BonusVaucherExpHearth = 30
    else
    BonusVaucherExpHearth = 0.0
    end
-- exp card
   
        local staminaMinutes = creature:getStamina()
        staminaExpBonusClient = 0
       
        if staminaMinutes > 2400 then
        staminaExpBonusClient = 50
        end

    if os.date("%A") == "Saturday" or os.date("%A") == "Sunday" then
    BonusExpDayClient = 100
    else
    BonusExpDayClient = 0
    end   
       
local daysvipclient = creature:getVipDays()   
if daysvipclient > 0 then
vipClientExp = 30
else
vipClientExp = 0
end
       
creature:setStoreXpBoost(vipClientExp + BonusExpDayClient + staminaExpBonusClient + BonusVaucherExpHearth)


   return true
end
 
Back
Top