• 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
123
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) +...
I have this script running in xml engines. Can you convert it to tfs 1.2?
XML:
<action itemid="2270" script="manarune.lua"  />
Lua:
function onUse(cid, item, frompos, item2, topos)

local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)

-- Exhausted Settings --
local exhausted_seconds = 1 -- How many seconds manarune will be unavailible to use. --
local exhausted_storagevalue = 1555 -- Storage Value to store exhaust. It MUST be unused! --
-- Exhausted 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)

-- We check the charges. --
if(item.type > 1) then
-- Exhausted check. --
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
-- Entity is player? --
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(topos,28)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerSay(cid,"Mana UUPP!!!",1)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doChangeTypeItem(item.uid, item.type - 1)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You can use this rune only on players.")
end
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
end
else
if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue)) then
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
else
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(topos,28)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerSay(cid,"Mana UUPP!!!",1)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doRemoveItem(item.uid, 1)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You can use this rune only on players.")
end
end
end

return 1
end
 
It hasn't been tested yet. Let me ask your source if it has "Game.sendAnimatedText". If it doesn't, you can change it to
Lua:
player:addMana(manaToAdd)
player:say("Your mana has been increased by " .. manaToAdd .. " points!", TALKTYPE_ORANGE_1)

Lua:
function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if not player then
        return false
    end

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

    -- Exhaustion Settings --
    local exhausted_seconds = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!!!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:transform(item.type - 1)
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        else
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!!!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
 
Last edited:
It hasn't been tested yet. Let me ask your source if it has "Game.sendAnimatedText". If it doesn't, you can change it to
Lua:
player:addMana(manaToAdd)
player:say("Your mana has been increased by " .. manaToAdd .. " points!", TALKTYPE_ORANGE_1)

Lua:
function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if not player then
        return false
    end

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

    -- Exhaustion Settings --
    local exhausted_seconds = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos)
                player:say("Mana UUPP!!!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:transform(item.type - 1)
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        else
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos)
                player:say("Mana UUPP!!!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
The script works
but I want it to write the value that was added, as in the picture
TY
 
You're talking about when to use the mana rune and display values and colors over the player, correct? In this case, it is the 'Game.sendAnimatedText' function... I asked a question before: does your source have 'Game.sendAnimatedText'? If you don't have it, you need to add this function to your source so that it works by displaying colored values in a simple way.
Post automatically merged:

change this
Lua:
 Game.sendAnimatedText("+" .. mana_add .. " Mana", topos)
to
Lua:
 Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
Ah, I had forgotten those details! Thanks for mentioning.
 
This works, thank you, but I have a problem. If the rune number is 1, the value does not appear and the rune ends, and if the number is 100, the value appears and the rune does not end.
 
try.
Lua:
function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if not player then
        return false
    end

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

    -- Exhaustion Settings --
    local exhausted_seconds = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                
                if mana_add > 1 then
                    item:transform(item.type - 1)
                else
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
            player:sendCancelMessage("You are exhausted.")
        else
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(topos, 28)
                player:getPosition():sendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                if mana_add > 1 then
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(frompos, CONST_ME_POFF)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
 
The rune ends if the number is only 1
2 manarune no end
2 + no end
Post automatically merged:

I found this problem too
Lua:
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
 
Last edited:
Show errors
or whats the problem?
A rune does not end unless the number of runes is 1
and when i use i got this \/
Lua:
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
 
A rune does not end unless the number of runes is 1
and when i use i got this \/
Lua:
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z
ERROR: invalid effect id 0
at:
    [C++]: ?parseMagicEffect@ProtocolGame@@AAEXABV?$shared_object_ptr@VInputMessage@@@stdext@@@Z

Remove all topos or frompos in sendMagicEffect, leave only numbers or effect(CONST_ME_MAGIC_BLUE)


Ex.:
Lua:
player:getPosition():sendMagicEffect(10)
 
I have this script running in xml engines. Can you convert it to tfs 1.2?
XML:
<action itemid="2270" script="manarune.lua"  />
Lua:
function onUse(cid, item, frompos, item2, topos)

local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)

-- Exhausted Settings --
local exhausted_seconds = 1 -- How many seconds manarune will be unavailible to use. --
local exhausted_storagevalue = 1555 -- Storage Value to store exhaust. It MUST be unused! --
-- Exhausted 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)

-- We check the charges. --
if(item.type > 1) then
-- Exhausted check. --
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
-- Entity is player? --
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(topos,28)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerSay(cid,"Mana UUPP!!!",1)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doChangeTypeItem(item.uid, item.type - 1)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You can use this rune only on players.")
end
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
end
else
if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue)) then
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
else
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(topos,28)
doSendMagicEffect(topos, CONST_ME_MAGIC_GREEN)
doSendAnimatedText(topos, mana_add, TEXTCOLOR_LIGHTBLUE)
doPlayerSay(cid,"Mana UUPP!!!",1)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
doRemoveItem(item.uid, 1)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You can use this rune only on players.")
end
end
end

return 1
end
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 = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if player then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                -- Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                
                if mana_add > 1 then
                    item:transform(item.itemid, item.type - 1)
                else
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        else
            -- Is the entity a player? --
            if player then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                -- Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                if mana_add > 1 then
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
 
Last edited:
Remove all topos or frompos in sendMagicEffect, leave only numbers or effect(CONST_ME_MAGIC_BLUE)


Ex.:
Lua:
player:getPosition():sendMagicEffect(10)
Ty
A rune does not end unless the number of runes is 1
Lua:
function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if not player then
        return false
    end

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

    -- Exhaustion Settings --
    local exhausted_seconds = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                
                if mana_add > 1 then
                    item:transform(item.type - 1)
                else
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        else
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                if mana_add > 1 then
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
 
Last edited:
Ty
A rune does not end unless the number of runes is 1
Lua:
function onUse(cid, item, frompos, item2, topos)
    local player = Player(cid)
    if not player then
        return false
    end

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

    -- Exhaustion Settings --
    local exhausted_seconds = 1 -- 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. --
    if (item.type > 1) then
        -- Exhaustion check. --
        if (os.time() > player:getStorageValue(exhausted_storagevalue)) then
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

              
                if mana_add > 1 then
                    item:transform(item.type - 1)
                else
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        else
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        end
    else
        if (os.time() < player:getStorageValue(exhausted_storagevalue)) then
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        else
            -- Is the entity a player? --
            if (isPlayer(item2.uid)) then
                player:getPosition():sendMagicEffect(10)
                player:getPosition():sendMagicEffect(10)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:addMana(mana_add)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)

                if mana_add > 1 then
                    item:remove(1)
                end
            else
                player:getPosition():sendMagicEffect(10)
                player:sendCancelMessage("You can only use this rune on players.")
            end
        end
    end

    return true
end
Lua:
item:transform(item.type - 1) >> item:transform(item.itemid, item.type - 1)
 
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 = 1 -- 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_ORANGE_1)
                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("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:
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 = 1 -- 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 (os.time() > player:getStorageValue(exhausted_storagevalue)) then
                player:addMana(mana_add)
                player:say("Mana UUPP!", TALKTYPE_ORANGE_1)
                player:getPosition():sendMagicEffect(10)
                Game.sendAnimatedText("+" .. mana_add .. " Mana", topos, TEXTCOLOR_LIGHTBLUE)
                player:setStorageValue(exhausted_storagevalue, os.time() + exhausted_seconds)
                item:remove(1)
        else
            player:getPosition():sendMagicEffect(10)
            player:sendCancelMessage("You are exhausted.")
        end


    return true
end
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
 
Back
Top