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

RevScripts tfs 1.4+ Stand on item xxx and get constanly hp/mp healed

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,312
Reaction score
135
Hey please for a help for such a script


if player stand on item id xxxx player constanlly get healed every xx ms/time and xx % of hp/mp and x ammount of soul gain

:))
 
When you click on the item, it is removed and heals an amount of MP/HP every time interval, correct?

Found it here, it should work for you. It's a revscript made by Xikini.
 
When you click on the item, it is removed and heals an amount of MP/HP every time interval, correct?

Found it here, it should work for you. It's a revscript made by Xikini.
its way different of what i want , unless it may be edited in my needs, but im not programmer at all so its unknown maze for me
 
1693319707579.png
its way different of what i want , unless it may be edited in my needs, but im not programmer at all so its unknown maze for me

joined nov22, 2008.



We have to try to learn some things a little, right? Or at least try. Come on, don't be discouraged, you can learn something, or at least have tried.
 
View attachment 78002


joined nov22, 2008.



We have to try to learn some things a little, right? Or at least try. Come on, don't be discouraged, you can learn something, or at least have tried.
i learned to read abit a script and edit abit in this time + i had many years brakes from tibia working, but honestly all who knows me , knows i hate programing, i dont like it... codes is worst part for me in working in my projects... sicne its the sizif stone for me...
 
@Lbtg

try this code, change config to match what you want
Lua:
local config = {
    position = Position(100, 100, 7), -- floor pos where player need to stand
    healthRegen = 10, -- life gain/interval
    manaRegen = 10, -- mana gain/interval
    soulRegen = 1, -- soul gain/interval
    interval = 2 -- interval in seconds
}

local function regeneratePlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    if player:getPosition() == config.position then
        player:addHealth(config.healthRegen)
        player:addMana(config.manaRegen)
        player:addSoul(config.soulRegen)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(regeneratePlayer, config.interval * 1000, player:getId())
    end
end

local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() then
        addEvent(regeneratePlayer, config.interval * 1000, creature:getId())
    end
    return true
end
moveevent:position(config.position)
moveevent:register()
 
Last edited:
@Lbtg

try this code, change config to match what you want
Lua:
local config = {
    position = Position(100, 100, 7), -- floor pos where player need to stand
    healthRegen = 10, -- life gain/interval
    manaRegen = 10, -- mana gain/interval
    soulRegen = 1, -- soul gain/interval
    interval = 2 -- interval in seconds
}

local function regeneratePlayer(player)
    if player and player:getPosition() == config.position then
        player:addHealth(config.healthRegen)
        player:addMana(config.manaRegen)
        player:addSoul(config.soulRegen)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(regeneratePlayer, config.interval * 1000, player)
    end
end

local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() then
        addEvent(regeneratePlayer, config.interval * 1000, creature)
    end
    return true
end
moveevent:position(config.position)
moveevent:register()
seems epic , thanks alot, but can you please remake it so if player stand on item id XXXX this effect is happpening, and if item dissapear not anymore under player heals stops ofc.


now it looks like you set up an x/y/z location that on this location this boost happens
 
seems epic , thanks alot, but can you please remake it so if player stand on item id XXXX this effect is happpening, and if item dissapear not anymore under player heals stops ofc.


now it looks like you set up an x/y/z location that on this location this boost happens
so, its an item?

Lua:
local config = {
    itemId = 1234, -- ID of the item that activates the regeneration
    healthRegen = 10, -- life gain/interval
    manaRegen = 10, -- mana gain/interval
    soulRegen = 1, -- soul gain/interval
    interval = 2 -- interval in seconds
}

local function regeneratePlayer(cid)
    local player = Player(cid)
    if not player then
        return
    end

    if Tile(player:getPosition()):getItemById(config.itemId) then
        player:addHealth(config.healthRegen)
        player:addMana(config.manaRegen)
        player:addSoul(config.soulRegen)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(regeneratePlayer, config.interval * 1000, player:getId())
    end
end

local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() and item:getId() == config.itemId then
        addEvent(regeneratePlayer, config.interval * 1000, creature:getId())
    end
    return true
end
moveevent:id(config.itemId)
moveevent:register()
 
Last edited:
so, its an item?

Lua:
local config = {
    itemId = 1234, -- ID of the item that activates the regeneration
    healthRegen = 10, -- life gain/interval
    manaRegen = 10, -- mana gain/interval
    soulRegen = 1, -- soul gain/interval
    interval = 2 -- interval in seconds
}

local function regeneratePlayer(player)
    if player and Tile(player:getPosition()):getItemById(config.itemId) then
        player:addHealth(config.healthRegen)
        player:addMana(config.manaRegen)
        player:addSoul(config.soulRegen)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(regeneratePlayer, config.interval * 1000, player)
    end
end

local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() and item:getId() == config.itemId then
        addEvent(regeneratePlayer, config.interval * 1000, creature)
    end
    return true
end
moveevent:id(config.itemId)
moveevent:register()
yeah,

i want to make a rune simmilar to magic wall rune, so like player shot on ground and make item xxx and that item xx does this healings.


btw interval can be set to 0.1 or 0.5 etc ?
Post automatically merged:

so, its an item?

Lua:
local config = {
    itemId = 1234, -- ID of the item that activates the regeneration
    healthRegen = 10, -- life gain/interval
    manaRegen = 10, -- mana gain/interval
    soulRegen = 1, -- soul gain/interval
    interval = 2 -- interval in seconds
}

local function regeneratePlayer(player)
    if player and Tile(player:getPosition()):getItemById(config.itemId) then
        player:addHealth(config.healthRegen)
        player:addMana(config.manaRegen)
        player:addSoul(config.soulRegen)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        addEvent(regeneratePlayer, config.interval * 1000, player)
    end
end

local moveevent = MoveEvent()
function moveevent.onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() and item:getId() == config.itemId then
        addEvent(regeneratePlayer, config.interval * 1000, creature)
    end
    return true
end
moveevent:id(config.itemId)
moveevent:register()

how to make this script work ? xd shall i made this item id xxx on items.xml have duration and decay to '0' ?
 
Last edited:
yeah,

i want to make a rune simmilar to magic wall rune, so like player shot on ground and make item xxx and that item xx does this healings.


btw interval can be set to 0.1 or 0.5 etc ?
I've never tested an addEvent script with that time, you can try using 0.5 instead of 1, but I don't know if its safe or not.

about rune, just copy your magicwall rune script and change the id

oh, you don't have the item with decay? yes, you can use items.xml to make it decay
 
I've never tested an addEvent script with that time, you can try using 0.5 instead of 1, but I don't know if its safe or not.

about rune, just copy your magicwall rune script and change the id

oh, you don't have the item with decay? yes, you can use items.xml to make it decay
aha oky, so it doesnt work, i stand on xxx id and nothing happens, tho i cannot seee now if there is any errors(console got spammed by another bug with trying to fix..)
 
aha oky, so it doesnt work, i stand on xxx id and nothing happens, tho i cannot seee now if there is any errors(console got spammed by another bug with trying to fix..)
you mean with half time? or script doesnt work with 1 second or more?
 
You shouldn't pass disposable objects (userdata) like creature to addEvent
Try execute this script and immediately logout/klick that player to make event execute once player is no longer there.

with config.lua like:
Lua:
warnUnsafeScripts = false
convertUnsafeScripts = false

Results might surprise you ;)

do it like that instead:
Lua:
local function doSomething(cid)
   local player = Player(cid)
   if not player then
      return
   end
 
   player:addHealth(100)
end


local cid = player:getId()
addEvent(doSomething, 5000, cid)
 
You shouldn't pass disposable objects (userdata) like creature to addEvent
Try execute this script and immediately logout/klick that player to make event execute once player is no longer there.

with config.lua like:
Lua:
warnUnsafeScripts = false
convertUnsafeScripts = false

Results might surprise you ;)

do it like that instead:
Lua:
local function doSomething(cid)
   local player = Player(cid)
   if not player then
      return
   end
 
   player:addHealth(100)
end


local cid = player:getId()
addEvent(doSomething, 5000, cid)
made the necessary changes, thanks.
 
Back
Top