Lava Titan
Developer
Hey, I created this to regenerate stamina while people are in trainers but my loop is not working correctly I guess, cuz I left my char there for alot of hours with 0 stamina and when I woke up it still had 0 stamina XD
Could someone have a look and tell me what am I doing wrong please?
Thanks <3
Could someone have a look and tell me what am I doing wrong please?
Thanks <3
Code:
local STORAGE = 616261
local EXHAUST_STORAGE = 616262
local function loopHealStamina(playerId)
local player = Player(playerId)
if not player then
return
end
if player:getExhaustion(EXHAUST_STORAGE) >= 1 then
addEvent(loopHealStamina, 1000, playerId)
return true
end
if player:getStorageValue(STORAGE) <= 0 then
return
end
if player:getStorageValue(STORAGE) >= 1 then
player:setStamina((player:getStamina() + 1))
addEvent(loopHealStamina, 1000, playerId)
end
return true
end
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil or player:isInGhostMode() then
return true
end
player:setStorageValue(STORAGE, 1)
loopHealStamina(player:getId())
player:setExhaustion(EXHAUST_STORAGE, 600000)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your stamina started regenerating.\n\nYou will receive 1 minute stamina for each 10 minutes training.")
return true
end
function onStepOut(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil or player:isInGhostMode() then
return true
end
player:setStorageValue(STORAGE, 0)
loopHealStamina(player:getId())
player:sendTextMessage(MESSAGE_INFO_DESCR, "Your stamina stopped regenerating.")
return true
end