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

Solved I need help for stamina system , please :c

Zekay

New Member
Joined
Dec 18, 2015
Messages
12
Reaction score
0
Hi , srry form my bad english I speak spanish , i dont knowt to edit the stamina system of my ot , I have this scryp in forgottenserver-master\data\creaturescripts\scripts , i've tfs 1.1 , i need to edit the speed of the regeneration of stamina , thanks :)

Code:
    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
 
Code:
local regainStaminaMinutes = offlineTime / 180

For each 180 seconds (3 minutes) offline you will gain 1 minute back.
You could for example change it to / 120 which would be 2 minutes offline = 1 minute back.

Same goes for happy hour
Code:
local happyHourStaminaRegen = (offlineTime - (maxNormalStaminaRegen * 180)) / 600
For each 600 seconds offline (10 minutes) you gain 1 minute of happy hour.

Edit:
I believe the 180 in happy hour calculation needs to match w.e you set it to for the normal stamina regain otherwise it will not work properly.
 
Back
Top