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

cant log in

BoRK

New Member
Joined
Dec 20, 2014
Messages
3
Reaction score
0
Using TFS 1.0
HTML:
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()
    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)
   
    if loginProtectionTime > 0 then
        player:addCondition(loginProtection)
    end
   
    player:registerEvent("PlayerDeath")
    return true
end

JENEqr.jpg
 
I dont really know how to code but trying to figure this out by observation.

So I was able to make it work and let me log in like this
Code:
function onLogin (player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    local player = Player (player)
    local loginProtectionTime = configManager.getNumber(configKeys.LOGIN_PROTECTION_TIME)
    local loginProtection = Condition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT)
   
    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
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
   
    if loginProtectionTime > 0 then
        player:addCondition(loginProtection)
    end
   
    player:registerEvent("PlayerDeath")
    return true
end

But in the original file there was one more line.
HTML:
function onLogin (player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    local player = Player (player)
    local loginProtectionTime = configManager.getNumber(configKeys.LOGIN_PROTECTION_TIME)
    local loginProtection = Condition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT)
    loginProtection:SetParameter(CONDITION_PARAM_TICKS, loginProtectionTime * 1000) <-------------This One

    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
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
   
    if loginProtectionTime > 0 then
        player:addCondition(loginProtection)
    end
   
    player:registerEvent("PlayerDeath")
    return true
end

I guess thats what is trying to set the amount of time you get of protection, but when i run this one i get this error.
8QVKQU.jpg

"loginProtection" seems to be defined in local already but maybe the rest of the line is not correct since it returns a nil value?
HTML:
local loginProtection = Condition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT)
 
in before the function onLogin, put this:
local config = {
loginProtection = true,
loginProtectionTime = 10 -- Login Protection Time / seconds
}
 
I played around with it and i got it to work like this. Does it do the job its supposed to do?
HTML:
local config = { -- <------------the suggested part
loginProtection = true,
loginProtectionTime = 10 -- Login Protection Time / seconds
}

function onLogin (player)
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    local player = Player (player)
    local loginProtectionTime = configManager.getNumber(configKeys.LOGIN_PROTECTION_TIME)
    local loginProtection = Condition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT)

    if loginProtection then -- <---------converted/do i still need this since the top has timer?
    SetParameter(CONDITION_PARAM_TICKS, loginProtectionTime * 1000)
    end

    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
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    if loginProtectionTime > 0 then
        player:addCondition(loginProtection)
    end

    player:registerEvent("PlayerDeath")
    return true
end

guessing the timers are interchangeable? can i use either or?
 
Last edited:
Back
Top