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

TFS 1.X+ TFS 1.3 useStamina

ftsystem

Member
Joined
Feb 17, 2019
Messages
19
Reaction score
5
When die an creature and it dies this window pops up in console!!

Tried everything and it didnt work

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:player@onGainExperience
data/events/scripts/player.lua:852: attempt to perform arithmetic on a nil value
stack traceback:
[C]: in function '__sub'
data/events/scripts/player.lua:852: in function 'useStamina'
data/events/scripts/player.lua:943: in function <data/events/scripts/player.lua:908>
 
Code:
local playerId = player:getId()

    local currentTime = os.time()

    local timePassed = currentTime - nextUseStaminaTime[playerId]

    if timePassed <= 0 then

        return

    end

  

    if timePassed > 60 then

        if staminaMinutes > 2 then

            staminaMinutes = staminaMinutes - 2

            else

            staminaMinutes = 0

        end

        nextUseStaminaTime[playerId] = currentTime + 120

        else

        staminaMinutes = staminaMinutes - 1

        nextUseStaminaTime[playerId] = currentTime + 60

    end

    player:setStamina(staminaMinutes)

end



local function useStaminaXp(player)

    local staminaMinutes = player:getExpBoostStamina() / 60

    if staminaMinutes == 0 then

        return

    end

  

    local playerId = player:getId()

    local currentTime = os.time()

    local timePassed = currentTime - nextUseXpStamina[playerId]

    if timePassed <= 0 then

        return

    end

  

    if timePassed > 60 then

        if staminaMinutes > 2 then

            staminaMinutes = staminaMinutes - 2

            else

            staminaMinutes = 0

        end

        nextUseXpStamina[playerId] = currentTime + 120

        else

        staminaMinutes = staminaMinutes - 1

        nextUseXpStamina[playerId] = currentTime + 60

    end

    player:setExpBoostStamina(staminaMinutes * 60)

end



function Player:eek:nGainExperience(source, exp, rawExp)

    if self:getStorageValue(12345) >= os.time() then -- exp custom

        exp = exp * 2

    end

end



function Player:eek:nGainExperience(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

  

    -- Experience Stage Multiplier

    local expStage = Game.getExperienceStage(self:getLevel())

    exp = exp * expStage

    baseExp = rawExp * expStage

    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then

        displayRate = expStage

        else

        displayRate = 1

    end

  

    -- Store Bonus

    useStaminaXp(self) -- Use store boost stamina

    local Boost = self:getExpBoostStamina()

    local stillHasBoost = Boost > 0

    local storeXpBoostAmount = stillHasBoost and self:getStoreXpBoost() or 0

    self:setStoreXpBoost(storeXpBoostAmount)

  

    if (storeXpBoostAmount > 0) then

        exp = exp + (baseExp * (storeXpBoostAmount/100)) -- Exp Boost

    end

  

    -- Stamina Bonus

    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:setStaminaXpBoost(150)

            elseif staminaMinutes <= 840 then

            exp = exp * 0.5 --TODO destroy loot of people with 840- stamina

            self:setStaminaXpBoost(50)

            else

            self:setStaminaXpBoost(100)

        end

    end

  

    self:setBaseXpGain(displayRate * 100)

  

    if self:isVip() then -- Checking if is vip to set exp

        exp = exp * VIP_SYSTEM_CONFIG.expBonus

    end   



    return exp

end



function Player:eek:nLoseExperience(exp)

    return exp

end
 
Back
Top