I did this simple math action for accounts that have only one character, so you do not have to check if the character has already recovered the stamina you wanted.
You put this action after you leave the game and do not disable cavebot.

I made it work with hours or minutes.

Hours:

local StaminaReturn = 40 --hours, no stamina bonus
--======================================
local MathStamina = math.abs($stamina/60 - StaminaReturn)*3

wait(MathStamina*3600000)


Minutes:

local StaminaReturn = 2400 --minutes
--======================
local MathStamina = math.abs($stamina - StaminaReturn)*3

wait(MathStamina*60000)


Example of how to use: my script corym venore

--Check Stamina
local StaminaReturn = 40 --hours, no stamina bonus
--======================================
local MathStamina = math.abs($stamina/60 - StaminaReturn)*3

if $pzone then
if ($stamina <= stamina*60) or (getuseroption('closeclient')) then
setuseroption('staminaamount', 15)
setuseroption('closeclient', false)
if getuseroption('offline') and $premium then
gotolabel('Start', 'TrainerOff')
else
while $connected do
setsetting('Persistent/Scripts/Reconnect/Enabled', 'no')
logout()
end
if not $connected then
printerror(''..$name..' - Corym [Venore] - Logout DP')
wait(MathStamina*3600000)
setsetting('Persistent/Scripts/Reconnect/Enabled', 'yes')
gotolabel(0, 'Location')
end
end
else
gotolabel('Start2','City')
end
else
gotolabel($wptid-2, 'City')
end


I put the codes on the lines 2-4, 17-22

line 21
gotolabel(0, 'Location')

Returns the character into the dp if he is training off or inside the dp and the hunt begins.