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

double exp

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
Code:
local days = {
    [10] = '00:00', -- [day] = 'hour(s):minute(s)'
    [11] = '12:00'
}

function onLogin(cid)
    local d = days[os.date('*t').day]
    local os, h = os.date('%X'):sub(1, 5), {'', ''}
   
    if d then
       h[1] = os:sub(1, 2)..os:sub(-2)
       h[2] = d:sub(1, 2)..d:sub(-2)
       
       if tonumber(h[1]) > tonumber(h[2]) then
           doPlayerSetRate(cid, SKILL__LEVEL, 2.0)
           doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Today is a day of double experience, enjoy!')
       end
    end
   
    return true
end





I would like to convert this script to tfs 1.x +

but does not have the function doPlayerSetRate
 
in data/events/player.lua

below
Lua:
 function Player:onGainExperience(source, exp, rawExp)
      if not source or source:isPlayer() then
      return exp
      end

if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
      useStamina(self)
      local staminaMinutes = self:getStamina()
      if staminaMinutes > 2400 and self:isPremium() then
      self:addCondition(onExperienceStamina(50))
      elseif staminaMinutes <= 840 then
      self:removeCondition(CONDITION_ATTRIBUTES, 250)
      end end

add:
Lua:
exp = exp * eventFunctionDoubleXp(self, 2)


then add to global.lua
Lua:
local days = {
    [10] = '00:00', -- [day] = 'hour(s):minute(s)'
    [11] = '12:00'
}

function eventFunctionDoubleXp(self, rate)
    local rate = rate ~= nil and rate or 1
    local d = days[os.date('*t').day]
    local os, h = os.date('%X'):sub(1, 5), {'', ''}
    if d then
       h[1] = os:sub(1, 2)..os:sub(-2)
       h[2] = d:sub(1, 2)..d:sub(-2)
     
       if tonumber(h[1]) > tonumber(h[2]) then
        self:sendTextMessage(MESSAGE_INFO_DESCR, 'Today is a day of double experience, enjoy!')
        return rate
       end
    end
    return 1
end
 
I think this would conflict with the extra VIP exp

Code:
function Player:onGainExperience(source, exp, rawExp)
    if not source or source:isPlayer() then
        return exp
    end
    if self:isVip() then
        exp = exp * 1.1
    end
 
Back
Top