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

Error on login

ZeeBeast

Preferable Beta Tester
Joined
Dec 5, 2013
Messages
206
Reaction score
10
Location
United States
So my server runs with no errors. But as soon as I try to log in to any character... I get this message:
Code:
Shaun has logged in.

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/offlinetraining.lua:onLogin
data/creaturescripts/scripts/others/offlinetraining.lua:4: attempt to call method 'getOfflineTrainingSkill' (a nil value)
stack traceback:
        [C]: in function 'getOfflineTrainingSkill'
        data/creaturescripts/scripts/others/offlinetraining.lua:4: in function <data/creaturescripts/scripts/others/offlinetraining.lua:1>

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/logout.lua:onLogout
data/creaturescripts/scripts/others/logout.lua:3: attempt to index global 'nextUseStaminaTime' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/others/logout.lua:3: in function <data/creaturescripts/scripts/others/logout.lua:1>
Shaun has logged out.
Does anyone know how I could fix this?
 
Offline training:
Code:
function onLogin(player)
    local lastLogout = player:getLastLogout()
    local offlineTime = lastLogout ~= 0 and math.min(os.time() - lastLogout, 86400 * 21) or 0
    local offlineTrainingSkill = player:getOfflineTrainingSkill()
    if offlineTrainingSkill == -1 then
        player:addOfflineTrainingTime(offlineTime * 1000)
        return true
    end

    player:setOfflineTrainingSkill(-1)

    if offlineTime < 600 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must be logged out for more than 10 minutes to start offline training.")
        return true
    end

    local trainingTime = math.max(0, math.min(offlineTime, math.min(43200, player:getOfflineTrainingTime() / 1000)))
    player:removeOfflineTrainingTime(trainingTime * 1000)

    local remainder = offlineTime - trainingTime
    if remainder > 0 then
        player:addOfflineTrainingTime(remainder * 1000)
    end

    if trainingTime < 60 then
        return true
    end

    local text = "During your absence you trained for"
    local hours = math.floor(trainingTime / 3600)
    if hours > 1 then
        text = string.format("%s %d hours", text, hours)
    elseif hours == 1 then
        text = string.format("%s 1 hour", text)
    end

    local minutes = math.floor((trainingTime % 3600) / 60)
    if minutes ~= 0 then
        if hours ~= 0 then
            text = string.format("%s and", text)
        end

        if minutes > 1 then
            text = string.format("%s %d minutes", text, minutes)
        else
            text = string.format("%s 1 minute", text)
        end
    end

    text = string.format("%s.", text)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)

    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    local topVocation = not promotion and vocation or promotion

    local updateSkills = false
    if isInArray({SKILL_CLUB, SKILL_SWORD, SKILL_AXE, SKILL_DISTANCE}, offlineTrainingSkill) then
        local modifier = topVocation:getAttackSpeed() / 1000
        updateSkills = player:addOfflineTrainingTries(offlineTrainingSkill, (trainingTime / modifier) / (offlineTrainingSkill == SKILL_DISTANCE and 4 or 2))
    elseif offlineTrainingSkill == SKILL_MAGLEVEL then
        local gainTicks = topVocation:getManaGainTicks() * 2
        if gainTicks == 0 then
            gainTicks = 1
        end

        updateSkills = player:addOfflineTrainingTries(SKILL_MAGLEVEL, trainingTime * (vocation:getManaGainAmount() / gainTicks))
    end

    if updateSkills then
        player:addOfflineTrainingTries(SKILL_SHIELD, trainingTime / 4)
    end

    return true
end

And here is logout.lua:
Code:
function onLogout(player)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
    return true
end
 
In global.lua do you have this?
Code:
if nextUseStaminaTime == nil then
    nextUseStaminaTime = {}
end

attempt to call method 'getOfflineTrainingSkill' (a nil value) means the funciton "getOfflineTrainingSkill" does not exist in sources.
 
This is a default method in TFS 1.1:
https://github.com/otland/forgotten...d40bc17b029b748c38e94/src/luascript.cpp#L2140

https://github.com/otland/forgotten...28ddce7ac59bf8714a2bf2/src/player.h#L219-L220

https://github.com/otland/forgotten...c6625d322d60cf1e43ba/src/iologindata.cpp#L327

Seems you're running an older version of TFS that doesn't support offline training.
This function is tied to server/client data that isn't a post-built script or function.
Meaning you are unlikely to find a manual LUA implementation.

Updating your Distro would be the easiest way to fix this.
 
Last edited:
This is a default method in TFS 1.1:
https://github.com/otland/forgotten...d40bc17b029b748c38e94/src/luascript.cpp#L2140

https://github.com/otland/forgotten...28ddce7ac59bf8714a2bf2/src/player.h#L219-L220

https://github.com/otland/forgotten...c6625d322d60cf1e43ba/src/iologindata.cpp#L327

Seems you're running an older version of TFS that doesn't support offline training.
This function is tied to server/client data that isn't a post-built script or function.
Meaning you are unlikely to find a manual LUA implementation.

Updating your Distro would be the easiest way to fix this.
This server is TFS 1.2

EDIT:
I checked the links you gave me. The server I'm using has all the same lines.
 
Last edited:
Back
Top