• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Manarune aint working, why?

Marko999x

ArchezOt soon
Premium User
Joined
Dec 14, 2017
Messages
3,975
Solutions
104
Reaction score
3,108
Location
Germany
Hello I edited a script by myself but it does not work as I thought :D so I need quick ur help

I tried to make a manarune which heals different for every vocation. as explain Knight heals 300k mana and mage heals 700k mana but for some reasons the script does not work and I dont know why. ( no errors in console ) im using tfs 0.4

Code:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 750) -- time in seconds x1000
     function onUse(cid, item, fromPosition, itemEx, toPosition)
if exhaustion.check(cid, 4905) then
    doPlayerSendCancel(cid, "You cant heal when you got freezed.")
    return true
end

    if hasCondition(cid, CONDITION_EXHAUST) then
        return true
    end
  
    if not isPlayer(itemEx.uid) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You may only use this on players!")
        return true
    end
 
    if playerVoc == 1 then
    local pos = getThingPos(itemEx.uid)
    local kolor = 210 -- kolor napisu
        doPlayerAddMana(itemEx.uid, 250000)
        doSendMagicEffect(getThingPos(itemEx.uid), 31)
        doSendAnimatedText(getPlayerPosition(itemEx.uid),"+"..mana_add.."",kolor)
        doAddCondition(cid, exhaust)
    elseif playerVoc == 2 then
    local pos = getThingPos(itemEx.uid)
    local kolor = 210 -- kolor napisu
        doPlayerAddMana(itemEx.uid, 250000)
        doSendMagicEffect(getThingPos(itemEx.uid), 31)
        doSendAnimatedText(getPlayerPosition(itemEx.uid),"+"..mana_add.."",kolor)
        doAddCondition(cid, exhaust)
    elseif playerVoc == 3 then
    local pos = getThingPos(itemEx.uid)
    local kolor = 210 -- kolor napisu
        doPlayerAddMana(itemEx.uid, 250000)
        doSendMagicEffect(getThingPos(itemEx.uid), 31)
        doSendAnimatedText(getPlayerPosition(itemEx.uid),"+"..mana_add.."",kolor)
        doAddCondition(cid, exhaust)
    elseif playerVoc == 4 then
    local pos = getThingPos(itemEx.uid)
    local kolor = 210 -- kolor napisu
        doPlayerAddMana(itemEx.uid, 210000)
        doSendMagicEffect(getThingPos(itemEx.uid), 31)
        doSendAnimatedText(getPlayerPosition(itemEx.uid),"+"..mana_add.."",kolor)
        doAddCondition(cid, exhaust)
        end
    return true
end

Hopefully someone can help me with this
 
Solution
X
Now its healing but 0 xD
Add me to discord.
I don't have a way to test the script.

check your pm with me from earlier today.

-- edit

Updated script after testing.
LUA:
local exhaust_time = 2000 -- 1 = millisecond
local colour, effect = 210, CONST_ME_STUN
local values = {
    [{1, 2, 5, 6}] = {600000}, -- [{vocation numbers}] = {mana_amount}
    [{3, 7}] = {400000},
    [{4, 8}] = {200000}
}

local exhaust_timer = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cur_time = os.mtime()
    if not exhaust_timer[cid] then
        exhaust_timer[cid] = 0
    end
    if exhaust_timer[cid] > cur_time then
        local next_time = (exhaust_timer[cid] - cur_time) / 1000
        doPlayerSendCancel(cid, "Exhausted. Can use...
Should've just added me on discord.
-shrug-

This is the one I created.
Haven't tested it yet though.

The main difference is using millisecond timing over the exhaust timer which rounds to the nearest second, therefore not being very accurate.
Also, it doesn't require a storage value. :p

LUA:
local exhaust_time = 2000 -- 1 = millisecond
local colour, effect = 210, CONST_ME_STUN
local values = {
    [{1, 2, 5, 6}] = {600000}, -- [{vocation numbers}] = {mana_amount}
    [{3, 7}] = {400000},
    [{4, 8}] = {200000}
}

local exhaust_timer = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cur_time = os.mtime()
    if not exhaust_timer[cid] then
        exhaust_timer[cid] = 0
    end
    if exhaust_timer[cid] > cur_time then
        local next_time = (exhaust_timer[cid] - cur_time) / 1000
        doPlayerSendCancel(cid, "Exhausted. Can use again in " .. next_time .. " seconds.")
        return true
    end
    exhaust_timer[cid] = 0 + exhaust_time
    local pid = itemEx.uid
    if not isCreature(pid) then
        return true
    end
    if not isPlayer(pid) then
        doPlayerSendCancel(cid, "This item can only be used on players.")
        return true
    end
    local voc = getPlayerVocation(pid)
    for v, k in pairs(values) do
        if isInArray(v, voc) then
            local cur_mana, max_mana, add = getCreatureMana(pid), getCreatureMaxMana(pid), 0
            if cur_mana + k[1] > max_mana then
                add = max_mana - cur_mana
            else
                add = k[1]
            end
            doSendMagicEffect(toPosition, effect)
            doSendAnimatedText(toPosition, "+" .. add .. "", colour)
            doCreatureAddMana(pid, add)
            break
        end
    end
    return true
end


To answer your question about your script..

"playerVoc" is never defined, therefore you never get past your if statements in order to add mana to the player.

-- edit
Minor change in script.
Please reload page to recopy.
 
Last edited by a moderator:
Should've just added me on discord.
-shrug-

This is the one I created.
Haven't tested it yet though.

The main difference is using millisecond timing over the exhaust timer which rounds to the nearest second, therefore not being very accurate.
Also, it doesn't require a storage value. :p

LUA:
local exhaust_time = 2000 -- 1 = millisecond
local colour, effect = 210, CONST_ME_STUN
local values = {
    [{1, 2, 5, 6}] = {600000}, -- [{vocation numbers}] = {mana_amount}
    [{3, 7}] = {400000},
    [{4, 8}] = {200000}
}

local exhaust_timer = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cur_time = os.mtime()
    if not exhaust_timer[cid] then
        exhaust_timer[cid] = 0
    end
    if exhaust_timer[cid] > cur_time then
        local next_time = (exhaust_timer[cid] - cur_time) / 1000
        doPlayerSendCancel(cid, "Exhausted. Can use again in " .. next_time .. " seconds.")
        return true
    end
    exhaust_timer[cid] = 0 + exhaust_time
    local pid = itemEx.uid
    if not isCreature(pid) then
        return true
    end
    if not isPlayer(pid) then
        doPlayerSendCancel(cid, "This item can only be used on players.")
        return true
    end
    local voc = getPlayerVocation(pid)
    for v, k in pairs(values) do
        if isInArray(v, voc) then
            local cur_mana, max_mana, add = getCreatureMana(pid), getCreatureMaxMana(pid), 0
            if cur_mana + k[1] > max_mana then
                add = max_mana - cur_mana
            else
                add = k[1]
            end
            doSendMagicEffect(toPosition, effect)
            doSendAnimatedText(toPosition, "+" .. add .. "", colour)
            doCreatureAddMana(pid, add)
            break
        end
    end
    return true
end


To answer your question about your script..

"playerVoc" is never defined, therefore you never get past your if statements in order to add mana to the player.

Not working + no error ^^
 
Now its healing but 0 xD
Add me to discord.
I don't have a way to test the script.

check your pm with me from earlier today.

-- edit

Updated script after testing.
LUA:
local exhaust_time = 2000 -- 1 = millisecond
local colour, effect = 210, CONST_ME_STUN
local values = {
    [{1, 2, 5, 6}] = {600000}, -- [{vocation numbers}] = {mana_amount}
    [{3, 7}] = {400000},
    [{4, 8}] = {200000}
}

local exhaust_timer = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cur_time = os.mtime()
    if not exhaust_timer[cid] then
        exhaust_timer[cid] = 0
    end
    if exhaust_timer[cid] > cur_time then
        local next_time = (exhaust_timer[cid] - cur_time) / 1000
        doPlayerSendCancel(cid, "Exhausted. Can use again in " .. next_time .. " seconds.")
        return true
    end
    exhaust_timer[cid] = cur_time + exhaust_time
    local pid = itemEx.uid
    if not isCreature(pid) then
        return true
    end
    if not isPlayer(pid) then
        doPlayerSendCancel(cid, "This item can only be used on players.")
        return true
    end
    local voc = getPlayerVocation(pid)
    for v, k in pairs(values) do
        if isInArray(v, voc) then
            local cur_mana, max_mana, add = getCreatureMana(pid), getCreatureMaxMana(pid), 0
            if cur_mana + k[1] > max_mana then
                add = max_mana - cur_mana
            else
                add = k[1]
            end
            doSendMagicEffect(toPosition, effect)
            doSendAnimatedText(toPosition, "+" .. k[1] .. "", colour)
            doCreatureAddMana(pid, add, false)
            break
        end
    end
    return true
end
 
Last edited by a moderator:
Solution
Back
Top