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

TFS 1.X+ Stamina regen when training for tfs 1.3

sagelantropus

New Member
Joined
Sep 28, 2018
Messages
17
Reaction score
0
Hi, I'm using Otservbr 12 (tfs 1.3)

I am looking for a script to regenerate stamina while training. I have found some but they doesn't work for me and doesn't give any error.
Could someone share with me a script that works on tfs 1.3??. Thanks in advance.
 
try with this one, and remember to register the action id on remere 👍
XML:
<movevent event="StepIn" actionid="25000" script="others/stamina_tile.lua" />
<movevent event="StepOut" actionid="25000" script="others/stamina_tile.lua" />

Lua:
staminaEvents = {}
local config = {
    timeToAdd = 5,
    addTime = 1,
}

local function addStamina(cid)
    local player = Player(cid)
    if not player then
        stopEvent(staminaEvents[cid])
        staminaEvents[cid] = nil
        return true
    end
    player:setStamina(player:getStamina() + config.addTime)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You received "..config.addTime.." minutes of stamina.")
    staminaEvents[cid] = addEvent(addStamina, config.timeToAdd * 60 * 1000, cid)
end

function onStepIn(creature)
    if creature:isPlayer() then
        creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You will receive "..config.addTime.." minute of stamina every "..config.timeToAdd.." minutes.")
        staminaEvents[creature:getId()] = addEvent(addStamina, config.timeToAdd * 60 * 1000, creature:getId())
    end
    return true
end

function onStepOut(creature)
    if creature:isPlayer() then
        stopEvent(staminaEvents[creature:getId()])
        staminaEvents[creature:getId()] = nil
    end
    return true
end
 
yes, I already tried that script but there was no result, it does not give error in the console either
 
XML:
<movevent event="StepIn" actionid="25000" script="others/stamina_tile.lua" />
<movevent event="StepOut" actionid="25000" script="others/stamina_tile.lua" />
Lua:
staminaEvents = {}
local config = {
timeToAdd = 5,
addTime = 1,
}

local function addStamina(cid)
local player = Player(cid)
if not player then
stopEvent(staminaEvents[cid])
staminaEvents[cid] = nil
return true
end
player:setStamina(player:getStamina() + config.addTime)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You received "..config.addTime.." minutes of stamina.")
staminaEvents[cid] = addEvent(addStamina, config.timeToAdd * 60 * 1000, cid)
end

function onStepIn(creature)
if creature:isPlayer() then
creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You will receive "..config.addTime.." minute of stamina every "..config.timeToAdd.." minutes.")
staminaEvents[creature:getId()] = addEvent(addStamina, config.timeToAdd * 60 * 1000, creature:getId())
end
return true
end

function onStepOut(creature)
if creature:isPlayer() then
stopEvent(staminaEvents[creature:getId()])
staminaEvents[creature:getId()] = nil
end
return true
end


Sorry, I'm stupid. I thought that it did not work, but it is the text that does not work, but the stamina is regenerated. Anyway, how can I fix the problem that the text does not appear?
 
Last edited:
I'm using a teleport to be teleported through and available trainer, but every time that I put an action ID on the tile, the teleport stop working. Does anyone have the same issue ?
 
Sorry, I'm stupid. I thought that it did not work, but it is the text that does not work, but the stamina is regenerated. Anyway, how can I fix the problem that the text does not appear?
To add a message, you can use this:
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "TEXT HERE")





I'm using a teleport to be teleported through and available trainer, but every time that I put an action ID on the tile, the teleport stop working. Does anyone have the same issue ?
To fix this, just add a corresponding movement to the action.
Lua:
local destination = {
newPos = Position(31912, 32354, 8)
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return
    end

    if player then   
        position:sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination.newPos)
        player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end
    return true
end
 
It's working now, but with another script.

But I have lots of trainers, and each one has a different position.
Post automatically merged:

To add a message, you can use this:
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "TEXT HERE")

Where specific ?

Thank you for your help.
 
Last edited:
Back
Top