• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Player.lua error

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
936
Solutions
2
Reaction score
57
Using tfs 1.2
So i was chilling, killing monsters and i noticed that cosole gives me this error \/
Untitled.png

185 line
LUA:
local function useStamina(player)
    local staminaMinutes = player:getStamina()
    if staminaMinutes == 0 then
        return
    end

    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
Line 231
LUA:
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 * getRateFromTable(experienceStages, self:getLevel(), configManager.getNumber(configKeys.RATE_EXP))

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

    return exp
end
 
Solution
you have problems with the global variable
Code:
nextUseStaminaTime

check in your global.lua
Code:
if nextUseStaminaTime == nil then
    nextUseStaminaTime = {}
end

and login.lua
Code:
-- Stamina
    nextUseStaminaTime[player.uid] = 0
and logout.lua
Code:
local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
you have problems with the global variable
Code:
nextUseStaminaTime

check in your global.lua
Code:
if nextUseStaminaTime == nil then
    nextUseStaminaTime = {}
end

and login.lua
Code:
-- Stamina
    nextUseStaminaTime[player.uid] = 0
and logout.lua
Code:
local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
 
Solution
you have problems with the global variable
Code:
nextUseStaminaTime

check in your global.lua
Code:
if nextUseStaminaTime == nil then
    nextUseStaminaTime = {}
end

and login.lua
Code:
-- Stamina
    nextUseStaminaTime[player.uid] = 0
and logout.lua
Code:
local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
Yea my whole variables was messed up, restored everything and now its fine.
 

Similar threads

Back
Top