void Player::gainExperience(uint64_t gainExp, Creature* source)
{
if (hasFlag(PlayerFlag_NotGainExperience) || gainExp == 0 || staminaMinutes == 0) {
return;
}
addExperience(source, gainExp, true);
}
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); }
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);
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;
}
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;
}
if (gainExperience(gainExp, target))
tfs 1 has onGainExperience event in lua, you dont need to make changes in sources.Depending on your distro. If you're using 1.3 change (player.cpp)
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.
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;
}
Sorry did not work for menot 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
what's the indicator that someone is a vip player? (storage value?)Sorry did not work for me
if (self:getStorageValue(77777) == 1) then
exp = exp * 1.25
end
Using tfs 1.3what'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
so then do what i suggested, the code i posted should be put inside PlayernGainExperience in player eventsUsing tfs 1.3
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