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

Lua locking for script mana rune tfs 1.2

Madusa

Active Member
Joined
Sep 8, 2022
Messages
118
Reaction score
33
Location
Egypt
The mana rune works depending on the level and magic level
A message appears showing how much the dose has been increased
lick\/
Thanks in advance

manaup.png
 
Solution
It was solved, thank you ♥♥

will not remove runes if mana is full

mark as resolved

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    if not player then
        return false
    end

    local level = player:getLevel()
    local mlevel = player:getMagicLevel()

    -- Exhaustion Settings --
    local exhausted_seconds = 10 -- How many seconds the mana rune will be unavailable to use.
    local exhausted_storagevalue = 1555 -- Storage Value to store exhaustion state. MUST be an unused value!
    -- Exhaustion Settings END --

    -- Mana Formula Settings --
    -- You can use "level" and "mlevel" --
    local mana_minimum = (level * 3) + (mlevel * 5) - 50
    local mana_maximum = (level * 3) +...
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/ManaRune.lua:onUse
attempt to index a nil value
stack traceback:
        [C]: at 0x01400b2170
        [C]: in function 'sendAnimatedText'
        data/actions/scripts/ManaRune.lua:30: in function <data/actions/scripts/
ManaRune.lua:1>
1 No message appears with the added value
2 No exhausted
3 A rune does not end unless the number of runes is 1
Problems increased xD
No message appears with the added value
if you have full mana, no message!
No exhausted
the exhausted was for 1 second...
C]: in function 'sendAnimatedText'
it was in the script so it remained
A rune does not end unless the number of runes is 1
is removed when you use
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    if not player then
        return false
    end

    local level = player:getLevel()
    local mlevel = player:getMagicLevel()

    -- Exhaustion Settings --
    local exhausted_seconds = 10 -- How many seconds the mana rune will be unavailable to use.
    local exhausted_storagevalue = 1555 -- Storage Value to store exhaustion state. MUST be an unused value!
    -- Exhaustion Settings END --

    -- Mana Formula Settings --
    -- You can use "level" and "mlevel" --
    local mana_minimum = (level * 3) + (mlevel * 5) - 50
    local mana_maximum = (level * 3) + (mlevel * 5)
    -- Mana Formula Settings END --

    local mana_add = math.random(mana_minimum, mana_maximum)

    -- Checking charges. --
  
        -- Exhaustion check. --
    if(isPlayer(target)) then    
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
                player:addMana(mana_add)
                player:say("Mana UUPP!", TALKTYPE_WHISPER)
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", player:getPosition(), TEXTCOLOR_LIGHTBLUE)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("You can only use this rune on players.")
    end

    return true
end

1702357336346.png
 
Last edited:
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    if not player then
        return false
    end

    local level = player:getLevel()
    local mlevel = player:getMagicLevel()

    -- Exhaustion Settings --
    local exhausted_seconds = 10 -- How many seconds the mana rune will be unavailable to use.
    local exhausted_storagevalue = 1555 -- Storage Value to store exhaustion state. MUST be an unused value!
    -- Exhaustion Settings END --

    -- Mana Formula Settings --
    -- You can use "level" and "mlevel" --
    local mana_minimum = (level * 3) + (mlevel * 5) - 50
    local mana_maximum = (level * 3) + (mlevel * 5)
    -- Mana Formula Settings END --

    local mana_add = math.random(mana_minimum, mana_maximum)

    -- Checking charges. --
 
        -- Exhaustion check. --
    if(isPlayer(target)) then 
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
                player:addMana(mana_add)
                player:say("Mana UUPP!", TALKTYPE_WHISPER)
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
                -- Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("You can only use this rune on players.")
    end

    return true
end
It works well now and the rune ends, but the added value does not appear
It just shows Mana UUPP!
 
It works well now and the rune ends, but the added value does not appear
It just shows Mana UUPP!
if you have full mana, no message!
change
Lua:
-- Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
to
Lua:
Game.sendAnimatedText("+" .. mana_add .. " Mana", player:getPosition(), TEXTCOLOR_LIGHTBLUE)
 
Last edited:
It was solved, thank you ♥♥

will not remove runes if mana is full

mark as resolved

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    if not player then
        return false
    end

    local level = player:getLevel()
    local mlevel = player:getMagicLevel()

    -- Exhaustion Settings --
    local exhausted_seconds = 10 -- How many seconds the mana rune will be unavailable to use.
    local exhausted_storagevalue = 1555 -- Storage Value to store exhaustion state. MUST be an unused value!
    -- Exhaustion Settings END --

    -- Mana Formula Settings --
    -- You can use "level" and "mlevel" --
    local mana_minimum = (level * 3) + (mlevel * 5) - 50
    local mana_maximum = (level * 3) + (mlevel * 5)
    -- Mana Formula Settings END --

    local mana_add = math.random(mana_minimum, mana_maximum)

    -- Checking charges. --
 
        -- Exhaustion check. --
    if(isPlayer(target)) then 
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            if player:getMana() ~= player:getMaxMana() then
                player:addMana(mana_add)
                player:say("Mana UUPP!", TALKTYPE_WHISPER)
                 Game.sendAnimatedText("+" .. mana_add .. " Mana", player:getPosition(), 35)
                player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
              else
                player:getPosition():sendMagicEffect(CONST_ME_POFF)
                player:sendCancelMessage("Your mana is already full.")
  
            end 
        else
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendCancelMessage("You can only use this rune on players.")
    end

    return true
end
 
Last edited:
Solution
Back
Top