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

10% xp for vip/premium HELP

perre123

Game Developer
Joined
Jan 18, 2008
Messages
101
Reaction score
19
Location
Sweden
I would like to add for "VIP players", 10% increased exp. Searched for some code but was not successfull, anyone know how to add and where :) ?

thanks :)
 
Depending on your distro. If you're using 1.3 change (player.cpp)
Code:
void Player::gainExperience(uint64_t gainExp, Creature* source)
{
   if (hasFlag(PlayerFlag_NotGainExperience) || gainExp == 0 || staminaMinutes == 0) {
       return;
   }

   addExperience(source, gainExp, true);
}

to something like
Code:
void Player::gainExperience(uint64_t gainExp, Creature* source)
{
   if (hasFlag(PlayerFlag_NotGainExperience) || gainExp == 0 || staminaMinutes == 0) {
       return;
   }

   if(isPremium()) {
       gainExp = (gainExp * 1.10);//10% extra experience if player is premium.
   }

   addExperience(source, gainExp, true);
}
 
Depending on your distro. If you're using 1.3 change (player.cpp)
Code:
void Player::gainExperience(uint64_t gainExp, Creature* source)
{
   if (hasFlag(PlayerFlag_NotGainExperience) || gainExp == 0 || staminaMinutes == 0) {
       return;
   }

   addExperience(source, gainExp, true);
}

to something like
Code:
void Player::gainExperience(uint64_t gainExp, Creature* source)
{
   if (hasFlag(PlayerFlag_NotGainExperience) || gainExp == 0 || staminaMinutes == 0) {
       return;
   }

   if(isPremium()) {
       gainExp = (gainExp * 1.10);//10% extra experience if player is premium.
   }

   addExperience(source, gainExp, true);
}
Code:
void Player::onGainExperience(double& gainExp, Creature* target, bool multiplied)
{
    uint64_t tmp = experience;
    if (party && party->isSharedExperienceEnabled() && party->isSharedExperienceActive())
    {
        party->shareExperience(gainExp, target, multiplied);
        rateExperience(gainExp, target);
        return; //we will get a share of the experience through the sharing mechanism
    }

    if (gainExperience(gainExp, target))
        Creature::onGainExperience(gainExp, target, true);

    CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE);
    for (CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it)
        (*it)->executeAdvance(this, SKILL__EXPERIENCE, tmp, experience);
Code:
void Player::addExperience(uint64_t exp)
{
    uint32_t prevLevel = level;

    uint64_t nextLevelExp = Player::getExpForLevel(level + 1);
    if (Player::getExpForLevel(level) > nextLevelExp)
    {
        //player has reached max level
        levelPercent = 0;
        sendStats();
        return;
    }
Code:
bool Player::rateExperience(double& gainExp, Creature* target)
{
    if (hasFlag(PlayerFlag_NotGainExperience) || gainExp <= 0)
        return false;

    if (target->getPlayer())
        return true;

    gainExp *= rates[SKILL__LEVEL] * g_game.getExperienceStage(level,
        vocation->getExperienceMultiplier());
    if (g_config.getBool(ConfigManager::USE_STAMINA))
    {
        if (!hasFlag(PlayerFlag_HasInfiniteStamina))
        {
            int32_t minutes = getStaminaMinutes();
            if (minutes >= g_config.getNumber(ConfigManager::STAMINA_LIMIT_TOP))
            {
                if (isPremium() || !g_config.getBool(ConfigManager::STAMINA_BONUS_PREMIUM))
                    gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_ABOVE);
            }
            else if (minutes < (g_config.getNumber(ConfigManager::STAMINA_LIMIT_BOTTOM)) && minutes > 0)
                gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_UNDER);
            else if (minutes <= 0)
                gainExp = 0;
        }
        else if (isPremium() || !g_config.getBool(ConfigManager::STAMINA_BONUS_PREMIUM))
            gainExp *= g_config.getDouble(ConfigManager::RATE_STAMINA_ABOVE);
    }

    return true;
}
Only have these codes and did not work replacing any.
 
Code:
if (gainExperience(gainExp, target))

Shows that you indeed have a function called gainExperience. It seems like it's a bit different from the 1.3 one, post your Player::gainExperience
and i'll help you out unless someone beats me to it.
 
not sure if solved.. but i just added a line in events/player.lua

Code:
    -- VIP EXP
    if self:isVip() then
       exp = exp * 1.25
    end
 
Code:
if (gainExperience(gainExp, target))

Shows that you indeed have a function called gainExperience. It seems like it's a bit different from the 1.3 one, post your Player::gainExperience
and i'll help you out unless someone beats me to it.
Code:
bool Player::gainExperience(double& gainExp, Creature* target)
{
    if (!rateExperience(gainExp, target))
        return false;

#ifdef _MULTIPLATFORM76
    //soul regeneration
    if (gainExp >= level)
    {
        if (Condition* condition = Condition::createCondition(
            CONDITIONID_DEFAULT, CONDITION_SOUL, 4 * 60 * 1000))
        {
            condition->setParam(CONDITIONPARAM_SOULGAIN,
                vocation->getGainAmount(GAIN_SOUL));
            condition->setParam(CONDITIONPARAM_SOULTICKS,
                (vocation->getGainTicks(GAIN_SOUL) * 1000));
            addCondition(condition);
        }
    }
#endif

    addExperience((uint64_t)gainExp);
    return true;
}
This one :) ?
 
Sorry did not work for me :(
what's the indicator that someone is a vip player? (storage value?)
are you using tfs 1.x?
what strutz posted should work if you set if self:isVip() then to whatever you use to indicate vip players
such as:
Code:
if (self:getStorageValue(77777) == 1) then
    exp = exp * 1.25
end
 
what's the indicator that someone is a vip player? (storage value?)
are you using tfs 1.x?
what strutz posted should work if you set if self:isVip() then to whatever you use to indicate vip players
such as:
Code:
if (self:getStorageValue(77777) == 1) then
    exp = exp * 1.25
end
Using tfs 1.3
 
Fixed it,

this code did the job
Code:
function onLogin(cid)

local rate = 1.5 -- 50%
local config = {
true_vip = "You gain "..((rate - 1)*100).."% exp more now!",
false_vip = "If you become VIP you will get "..((rate - 1)*100).."% more experience",
vip = isPremium(cid)
}

if (config.vip == TRUE) then
doPlayerSetExperienceRate(cid, rate)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.true_vip)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.false_vip)
end
return TRUE
end
 
Back
Top