• 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+ Login Lua Script Error

Sp0tl3ss

Nestalia.org
Joined
Jul 19, 2014
Messages
279
Reaction score
12
Admin has logged in.

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/login.lua:eek:nLogin
data/creaturescripts/scripts/login.lua:16: attempt to call method 'getDepotLocker' (a nil value)
stack traceback:
[C]: in function 'getDepotLocker'
data/creaturescripts/scripts/login.lua:16: in function <data/creaturescripts/scripts/login.lua:10>
Admin has logged out.


any ideas? this is line 10-20 in login.lua
"Lines"
10 function onLogin(player)
11 local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
12 if player:getLastLoginSaved() <= 0 then
13 loginStr = loginStr .. ' Please choose your outfit.'
14 player:sendOutfitWindow()
15 for i = 1, #townIds do
16 local depotChest = player:getDepotLocker(townIds):addItem(1987, 1)
17 if depotChest then
18 depotChest:transform(2594)
19 end
20 end
 
Solution
Well, i can tell you that code for chest can be deleted unless you have an use for it. That will solve your problems.

That code is adding an item to the depot, which is not needed unless you want to do something specific.

Lua:
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
This is my login.lua and im using tfs 1.2
As far as I can see you are missing the townIds.
Also, the function is getDepotChest not Locker.
player:getDepotChest(depotId[, autoCreate = false])
 
As far as I can see you are missing the townIds.
Also, the function is getDepotChest not Locker.
player:getDepotChest(depotId[, autoCreate = false])
So replace "player:getDepotLocker(townIds):addItem(1987, 1)" with "player:getDepotChest(depotId[, autoCreate = false])"?

Code:
local events = {
    'PlayerDeath',
    'LevelSave',
    'SvargrondArenaKill',
    'DropLoot'
}

local townIds = {1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12}

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
        for i = 1, #townIds do
        local depotChest = player:getDepotChest(townIds):addItem(1987, 1)
            if depotChest then
                depotChest:transform(2594)
            end
        end
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    -- Stamina
    nextUseStaminaTime[player.uid] = 0
  
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end

    if player:getStorageValue(2038) == 1 then -- Task System register if still has task
        player:registerEvent("TaskKill")
    end

    for i = 1, #events do
        player:registerEvent(events[I])
    end
    return true
end[/I]
[CODE]
[I]
This is the full login.lua file[/I]
 
Last edited:
no, thats just a generic function. Parameters between [] are optional.

Code:
player:getDepotChest(LOOK FOR THE DEPOT ID):addItem(1987,1)
 
no, thats just a generic function. Parameters between [] are optional.

Code:
player:getDepotChest(LOOK FOR THE DEPOT ID):addItem(1987,1)
i changed the code to the one you posted got this error now the town ids are fine i swaped LOOK FOR THE DEPOT ID to the id of the depot.
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/login.lua:eek:nLogin
data/creaturescripts/scripts/login.lua:16: attempt to index a boolean value
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/login.lua:16: in function <data/creaturescripts/scripts/login.lua:10>
Admin has logged out.
 
local depotChest = player:getDepotChest(townIds):addItem(1987, 1) -----> local depotChest = player:getDepotChest(i):addItem(1987, 1)

You are giving the value i = 1 to townId.. meaning 1-12, townId is just a table.
 
local depotChest = player:getDepotChest(townIds):addItem(1987, 1) -----> local depotChest = player:getDepotChest(i):addItem(1987, 1)

You are giving the value i = 1 to townId.. meaning 1-12, townId is just a table.
still the same error..
"
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/login.lua:eek:nLogin
data/creaturescripts/scripts/login.lua:16: attempt to index a boolean value
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/login.lua:16: in function <data/creaturescripts/scripts/login.lua:10>
Spotless has logged out.
"
 
Code:
local events = {
    'PlayerDeath',
    'LevelSave',
    'SvargrondArenaKill',
    'DropLoot'
}

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
        for i = 1, 12 do
        local depotChest = player:getDepotChest(i):addItem(1987, 1)          
        end
            if depotChest then
                depotChest:transform(2594)
            end
    else
        if loginStr ~= '' then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end
        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
    -- Promotion
    local vocation = player:getVocation()
    local promotion = vocation:getPromotion()
    if player:isPremium() then
        local value = player:getStorageValue(STORAGEVALUE_PROMOTION)
        if not promotion and value ~= 1 then
            player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
        elseif value == 1 then
            player:setVocation(promotion)
        end
    elseif not promotion then
        player:setVocation(vocation:getDemotion())
    end
    if player:getStorageValue(2038) == 1 then -- Task System register if still has task
        player:registerEvent("TaskKill")
    end
    for i = 1, #events do
        player:registerEvent(events[I])
    end
    return true
end
 
this indeed fixed my errors i got trying to login but it still wont let me connect to the game



Edit: i can login with the sample chars so its some other problem now, huge thanks for youre time and support and i hope you have an amazing day sir!
 
I dont really know what you are trying to accomplish here.

depotChest is true or false in this case. You can not transform that into anything.
If you do not explain what you are trying to do, is hard to help you further than that.
 
I dont really know what you are trying to accomplish here.

depotChest is true or false in this case. You can not transform that into anything.
If you do not explain what you are trying to do, is hard to help you further than that.
i have not writhen these files :D but its fixed now thanks to you! :D
 
I dont really know what you are trying to accomplish here.

depotChest is true or false in this case. You can not transform that into anything.
If you do not explain what you are trying to do, is hard to help you further than that.
Hello so i can login using "rook sample" etc but the chars i create still makes errors
"
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/login.lua:eek:nLogin
data/creaturescripts/scripts/login.lua:14: attempt to index a boolean value
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/login.lua:14: in function <data/creaturescripts/scripts/login.lua:8>
Testmate has logged out.
"
 
test with this.
player:getDepotChest(i, true):addItem(1987, 1)

But again, if you dont tell me what you are trying to accomplish is hard to help you out. It may have more errors.
 
test with this.
player:getDepotChest(i, true):addItem(1987, 1)

But again, if you dont tell me what you are trying to accomplish is hard to help you out. It may have more errors.
i just want to enter the game :D, from what in understand this code it used for first login (i belive this is why the sample ones work) to set outfit the chest code i dont rly understand i think it adds a locker to depot chest or simular :D EDIT: feel free to add my discord "spotless#3377"
 
Well, i can tell you that code for chest can be deleted unless you have an use for it. That will solve your problems.

That code is adding an item to the depot, which is not needed unless you want to do something specific.

Lua:
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
This is my login.lua and im using tfs 1.2
 
Solution
Back
Top