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

Lua TFS 1.4.2 promotion & stamina

Gofrio

Member
Joined
Dec 24, 2022
Messages
29
Reaction score
12
Hello everyone! :) I have a small problem with promotion on my server, half players sometimes can take promotion from npc or sometimes he can't take promo anymore, its my login.lua everything is okay here?

Lua:
 -- Promotion

    local vocation = player:getVocation()

    local promotion = vocation:getPromotion()

    if player:isPremium() then

        local value = player:getStorageValue(PlayerStorageKeys.promotion)

        if value == 1 then

            player:setVocation(promotion)

        end

    elseif not promotion then

        player:setVocation(vocation:getDemotion())

    end

also someone can help me understand how works stamina? i want improve regeneration little.
regeneratestamina.lua
Lua:
function onLogin(player)
    if not configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        return true
    end

    local lastLogout = player:getLastLogout()
    local offlineTime = lastLogout ~= 0 and math.min(os.time() - lastLogout, 86400 * 21) or 0
    offlineTime = offlineTime - 600

    if offlineTime < 180 then
        return true
    end

    local staminaMinutes = player:getStamina()
    local maxNormalStaminaRegen = 2400 - math.min(2400, staminaMinutes)

    local regainStaminaMinutes = offlineTime / 180
    if regainStaminaMinutes > maxNormalStaminaRegen then
        local happyHourStaminaRegen = (offlineTime - (maxNormalStaminaRegen * 180)) / 600
        staminaMinutes = math.min(2520, math.max(2400, staminaMinutes) + happyHourStaminaRegen)
    else
        staminaMinutes = staminaMinutes + regainStaminaMinutes
    end

    player:setStamina(staminaMinutes)
    return true
end

Thanks for your help! :)
 
Back
Top