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

Help with working script

adamox223

New Member
Joined
Oct 21, 2017
Messages
99
Reaction score
4
Hello i need help with this script, because I can not add this... When we logout or die, regeneration is active, can you add this? i tried with login.lua but i am newbie and this have no results..

Code:
local config = {
    amount = 50, -- HPs by second
    time = 3600, -- seconds
    exhaust = {
        storage = 12412,
        time = 3601, -- Exhaust time seconds~
    }
}

local function doRegeneration(cid, amount, seconds)
    if seconds <= 0 then
        return false
    end
    doCreatureAddHealth(cid, amount)
    doCreatureAddMana(cid, amount)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    return addEvent(doRegeneration, 1000, cid, amount, seconds - 1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, config.exhaust.storage) then        
        return doPlayerSendCancel(cid, "You're exhausted.")
    end    
    doRemoveItem(item.uid, 1)
    doRegeneration(cid, config.amount, config.time)
    exhaustion.set(cid, config.exhaust.storage, config.exhaust.time)
    return true
end
 
Solution
i try with and here is errors
zveyhh.png
Sorry, forgot to adjust that part.
Re-copy. I edited my post above.
TFS Version?

open data/creaturescripts/scripts/login.lua and add this function at the top

Lua:
local function regen(cid, amount, seconds)
    if seconds <= 0 then
        return false
    end
    doCreatureAddHealth(cid, amount)
    doCreatureAddMana(cid, amount)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    return addEvent(regen, 1000, cid, amount, seconds - 1)
end

inside the function onLogin add this

Code:
if getPlayerStorageValue(cid, 12412) then
    regen(cid, 50, 3600)
end

note your timer will restart
 
TFS Version?

open data/creaturescripts/scripts/login.lua and add this function at the top

Lua:
local function regen(cid, amount, seconds)
    if seconds <= 0 then
        return false
    end
    doCreatureAddHealth(cid, amount)
    doCreatureAddMana(cid, amount)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    return addEvent(regen, 1000, cid, amount, seconds - 1)
end

inside the function onLogin add this

Code:
if getPlayerStorageValue(cid, 12412) then
    regen(cid, 50, 3600)
end

note your timer will restart
Could use a storage to hold the 'seconds' value, and if that value is above 0, then regen will continue when person logs back in.
 
Tfs 0.3.6, here is the errors :/

33eh6s8.png
----------------------------------------
----------------------------------------
replace your code with mine.

data/actions/scripts/regeboost.lua
Lua:
local config = {
    storage = 12412, -- exhaust
    recovery_amount = 50, -- HPs by second
    timer = 3600 -- seconds
}

local function doRegeneration(cid, recovery_amount)
    if not isPlayer(cid) then
        return true
    end
    if getPlayerStorageValue(cid, config.storage) >= 1 then
        doCreatureAddHealth(cid, recovery_amount)
        doCreatureAddMana(cid, recovery_amount)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) - 1)
        addEvent(doRegeneration, 1000, cid, recovery_amount)
    end
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) > 0 then 
        doPlayerSendCancel(cid, "Can only have one active buff of this type.")
        return true
    end
    setPlayerStorageValue(cid, config.storage, config.timer)
    addEvent(doRegeneration, 0, cid, config.recovery_amount)
    doRemoveItem(item.uid, 1)
    return true
end
-----------
add this script to..
data/creaturescripts/scripts/regeboost.lua
Lua:
local config = {
    storage = 12412, -- exhaust
    recovery_amount = 50 -- HPs by second
}

local function doRegeneration(cid, recovery_amount)
    if not isPlayer(cid) then
        return true
    end
    if getPlayerStorageValue(cid, config.storage) >= 1 then
        doCreatureAddHealth(cid, recovery_amount)
        doCreatureAddMana(cid, recovery_amount)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) - 1)
        addEvent(doRegeneration, 1000, cid, recovery_amount)
    end
    return true
end

function onLogin(cid)
    if getPlayerStorageValue(cid, config.storage) > 0 then 
        addEvent(doRegeneration, 0, cid, config.recovery_amount)
        return true
    end
    return true
end
-----------
REGISTER SCRIPT IN
data/creaturescripts/creaturescripts.xml
-----------
AND ALSO
data/creaturescripts/scripts/login.lua (somewhere at the bottom with the other registered events.)
 
Last edited:
----------------------------------------
----------------------------------------
replace your code with mine.

data/actions/scripts/regeboost.lua
Lua:
local config = {
    storage = 12412, -- exhaust
    recovery_amount = 50, -- HPs by second
    timer = 3600 -- seconds
}

local function doRegeneration(cid, recovery_amount)
    if not isPlayer(cid) then
        return true
    end
    if seconds >= 1 then
        doCreatureAddHealth(cid, recovery_amount)
        doCreatureAddMana(cid, recovery_amount)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) - 1)
        addEvent(doRegeneration, 1000, cid, recovery_amount)
    end
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) > 0 then
        doPlayerSendCancel(cid, "Can only have one active buff of this type.")
        return true
    end
    setPlayerStorageValue(cid, config.storage, config.timer)
    addEvent(doRegeneration, 0, cid, config.recovery_amount)
    doRemoveItem(item.uid, 1)
    return true
end
-----------
add this script to..
data/creaturescripts/scripts/regeboost.lua
Lua:
local config = {
    storage = 12412, -- exhaust
    recovery_amount = 50, -- HPs by second
    timer = 3600 -- seconds
}

local function doRegeneration(cid, recovery_amount)
    if not isPlayer(cid) then
        return true
    end
    if seconds >= 1 then
        doCreatureAddHealth(cid, recovery_amount)
        doCreatureAddMana(cid, recovery_amount)
        doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
        setPlayerStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) - 1)
        addEvent(doRegeneration, 1000, cid, recovery_amount)
    end
    return true
end

function onLogin(cid)
    if getPlayerStorageValue(cid, config.storage) > 0 then
        addEvent(doRegeneration, 0, cid, config.recovery_amount)
        return true
    end
    return true
end
-----------
REGISTER SCRIPT IN
data/creaturescripts/creaturescripts.xml
-----------
AND ALSO
data/creaturescripts/scripts/login.lua (somewhere at the bottom with the other registered events.)

that will restart the timer.. you could use exhaust storage value for seconds to continue executing script when player logs in and have doRegeneration in global since it's the same in both scripts

and unused variable; timer
 
Back
Top