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

Manarune doesnt work... [TFS 0.2.4]

Martiimeus

●тнυg●ℓιƒє● ρα¢ 4 єνєя
Joined
Feb 3, 2009
Messages
500
Reaction score
1
Location
gєямαηу
As the title says my manarune isn't working yet idk why heres the error code:

Code:
[27/07/2009 21:27:12] Lua Script Error: [Action Interface] 
[27/07/2009 21:27:12] data/actions/scripts/tools/xmanarune.lua:onUse

[27/07/2009 21:27:12] data/actions/scripts/tools/xmanarune.lua:39: attempt to call global 'comparePos' (a nil value)
[27/07/2009 21:27:12] stack traceback:
[27/07/2009 21:27:12] 	data/actions/scripts/tools/xmanarune.lua:39: in function <data/actions/scripts/tools/xmanarune.lua:17>

And heres the script:

PHP:
-- Script 70% by Noxu, 30% by Paukus for help(Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Noxu.

-- >>CONFIG<< --
local REMOVE_CHARGES = false
local MIN_MANA = 500
local MAX_MANA = 1000
local USE_STATS = true
local STORE_VALUE = 3567
local EXHAUST_TIME = 1
local ANIMATION_COLOR = 183
-- >>CONFIG<< --

local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05} -- Remove and/or comment it out if you wish not to use it.
local removeMana = 0

function onUse(cid, item, frompos, item2, topos)
    if isPlayer(item2.uid) == 1 then
        local maxMana = getPlayerMaxMana(item2.uid)
        if vocMultiply and getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
            removeMana = vocMultiply[getPlayerVocation(cid)]
        end
        local newMana = math.random(MIN_MANA, MAX_MANA)
        if USE_STATS then
            newMana = math.ceil(newMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (newMana * removeMana))
        end
        if (maxMana - newMana) < 0 then
            newMana = maxMana - getPlayerMana(cid)
        end
        if getPlayerMana(item2.uid) < maxMana then
            if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 then
                if REMOVE_CHARGES then
                    if item.type > 1 then
                        doChangeTypeItem(item.uid, item.type - 1)
                    else
                        doRemoveItem(item.uid, 1)
                    end
                end
                if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                    doSendMagicEffect(getPlayerPosition(cid), 12)
                    doPlayerSendTextMessage(cid, 23, "You received " .. newMana .. " mana.")
                else
                    doSendMagicEffect(getPlayerPosition(cid), 14)
                    doSendMagicEffect(getPlayerPosition(item2.uid), 12)
                    doPlayerSendTextMessage(item2.uid, 23, "You received " ..  newMana .. " mana from " .. getPlayerName(cid) .. ".")
                    doPlayerSendTextMessage(cid, 23, "You gave " .. getPlayerName(item2.uid) .. " " .. newMana .. " mana.")
                end
                doPlayerAddMana(item2.uid, 1000)
                doSendAnimatedText(getPlayerPosition(item2.uid), newMana, ANIMATION_COLOR)
            else
                doPlayerSendCancel(cid, "You are exhausted.")
            end
        else
            if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                doPlayerSendCancel(item2.uid, "Your mana is already full.")
            else
                doPlayerSendCancel(cid, getPlayerName(item2.uid) .. " mana is already full.")
            end
            doSendMagicEffect(getPlayerPosition(cid), 2)
        end
    else
        doPlayerSendCancel(cid, "You can only use this rune on players.")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
    return 1
end

-- Exhaustion system (Made by Alreth, bugfix by me)
-- DO NOT EDIT!
function exhaust(cid, storeValue, exhaustTime)
 
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storeValue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhaustTime == nil or exhaustTime < 0) then
        exhaustTime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhaustTime) then
        setPlayerStorageValue(cid, storeValue, newExhaust) 
        return 1
    else
        return 0
    end
end

If some1 would help me I'd rep him ofc^^

:wub:*Using Mystic Spirit*
 
Last edited:
Create a file in /data/actions/scripts called manarune.lua.
Now, open it and paste the following:


PHP:
-----------------------------------
--Created to make the script easy to manipulate
--If used without using server potion exhaust (EX: potExhaust = false), it will work regardless of server
--Remember, true = yes, false = no, in the config

function onUse(cid, item, frompos, item2, topos)
    --Config
    local reqml = 3         --Magic Level required to use it
    local reqlvl = 15       --Character Level required to use it
    local potExhaust = false    -- causes exhaust like potions (false creates seperate exhaust for mana rune)
    local minMana = 150     --Minimum amount of mana to be added
    local maxMana = 300         --Maximum amount of mana to be added
    local ani = 1           --Animation to be sent to player when used (these can be found in your global.lua; search for CONST_ME_)
    --If you don't want it to give health, set both to 0
    local minHealth = 150       --Minimum amount of health to be added
    local maxHealth = 300       --Maximum amount of health to be added
    --If you're not using potion exhaust (potExhaust = false) edit the following the way you'd like
    local storeValue = 50       --The storage value that will be used for exhaust if you have potexhaust to false
    local exhaustTime = 1       --Exhaust in seconds
    local infinite = false      --Will it cause rune to lose charges
    local canUseInPz = true    --If true, mana rune may be used in PZ, otherwise, it will not work.

    local player_say = "Ahhh..."                            --What player says after successfully using the mana rune
    local error_ml = "You don't have the required magic level to use that rune."    --What the cancel says when ml is too low
    local error_lvl = "You don't have the required magic level to use that rune."   --What the cancel says when level is too low
    local error_notPlayer = "You can only use this rune on players."        --What the cancel says when you try to use it on something not a player
    local error_exhaust = "You are exhausted."                  --What the cancel says when you are exhausted
    local error_pz = "You may not use this in Protected Zones." --What the cancel says when you are in PZ and canUseInPz is false
    ------------------------------------------- DO NOT EDIT BELOW THIS LINE!! -------------------------------------------

    ---------------------------START Check for Errors--------------------------------
    --If doesn't allow use in PZ, send poof and cancel message
    if canUseInPz == false  and getTilePzInfo(getPlayerPosition(cid)) == 1 then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_pz)
        return 0
    end
    --If not high enough level, send poof and cancel message
    if getPlayerLevel(cid) < reqlvl then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_lvl)
        return 0
    end

    --If ml is too low, send poof and cancel message
    if getPlayerMagLevel(cid) < reqml then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_ml)
        return 0
    end

    --If it's not a player, send poof and cancel message
    if item2.uid < 1 then
        doSendMagicEffect(frompos, CONST_ME_POFF)
        doPlayerSendCancel(cid, error_notPlayer)
        return 0
    end

    --Check if exhausted
    if potExhaust == false then --If not using Potion Exhaust
        if exhaust(cid, storeValue, exhaustTime) == 0 then
            doSendMagicEffect(frompos, CONST_ME_POFF)
            doPlayerSendCancel(cid, error_exhaust)
            return 0
        end
    else --If you are using potion exhaust
        if hasCondition(cid, CONDITION_EXHAUSTED) == 1 then
            doPlayerSendCancel(cid, error_exhaust)
            return 0
        end
    end

    ---------------------------END Check for Errors--------------------------------

    doSendMagicEffect(topos, ani)
    doPlayerAddHealth(item2.uid, math.random(minHealth, maxHealth))
    doPlayerAddMana(item2.uid, math.random(minMana, maxMana))
    if infinite == false then
        if item.type > 1 then
            doChangeTypeItem(item.uid,item.type-1)
        else
            doRemoveItem(item.uid,1)
        end
    end
end

--Exhaust System created by Alreth
--Edited by OsoSangre
function exhaust(cid, storeValue, exhaustTime)
    local newExhaust = os.time()
    local oldExhaust = getPlayerStorageValue(cid, storeValue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhaustTime == nil or exhaustTime < 0) then
        exhaustTime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhaustTime) then
        setPlayerStorageValue(cid, storeValue, newExhaust)
        return 1
    else
        return 0
    end
end


Lastly, add the following line to your actions.xml found in /data/actions

PHP:
<action itemid="2270" script="manarune.lua" allowfaruse="1" blockwalls="0" />
 
Well it gives now some effects but no mana ;(


HTML:
[29/07/2009 06:57:24] Lua Script Error: [Action Interface] 
[29/07/2009 06:57:24] data/actions/scripts/tools/xmanarune.lua:onUse

[29/07/2009 06:57:24] data/actions/scripts/tools/xmanarune.lua:76: attempt to call global 'doPlayerAddHealth' (a nil value)
[29/07/2009 06:57:24] stack traceback:
[29/07/2009 06:57:24] 	data/actions/scripts/tools/xmanarune.lua:76: in function <data/actions/scripts/tools/xmanarune.lua:6>
 
I could give you a magic level and level dependig manarune
here is it

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)

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

-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 12.33) + (mlevel * 4) - 50
local mana_maximum = (level * 13.5) + (mlevel * 5) 
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(pos, mana_add, TEXTCOLOR_PURPLE)
return doCombat(cid, combat, var)
end


This script is not by me! But i'm using it, too.
 
Back
Top