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

Solved 8.6 Mana Rune (Level based)

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
402
Solutions
2
Reaction score
65
Location
Sweden
_SOLVED_
Lua:
function onCastSpell(cid, item, fromPosition, toPosition)
    local level = getPlayerLevel(cid)
    local mana = math.random(level, (level*2))
   
    doPlayerAddMana(cid, mana)
    doSendAnimatedText(getPlayerPosition(cid), '+' .. mana, TEXTCOLOR_PURPLE)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)          
end


_PROBLEM_
I can get it to work with a number range (50 > 100)

But I can not get it to work with level numbers:
Lua:
function onCastSpell(cid, item, fromPosition, toPosition)
    local min = level
    local max = (level*2)
    local mana = math.random(min, max)
  
    doPlayerAddMana(cid, mana)
    doSendAnimatedText(getPlayerPosition(cid), '+' .. mana, TEXTCOLOR_PURPLE)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)        
end

The error I get in the console is:
attempt to perform arithmetic on global 'level' (a nil value)
 
Last edited:
Solution
Lua:
function onCastSpell(cid, item, fromPosition, toPosition)
    local level = getPlayerLevel(cid)
    local mana = math.random(level, (level*2))
   
    doPlayerAddMana(cid, mana)
    doSendAnimatedText(getPlayerPosition(cid), '+' .. mana, TEXTCOLOR_PURPLE)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)          
end

This worked, didn't have to move it to actions. Thanks for your help! :)
because you never defined level
local level = getPlayerLevel(cid)
put that under onUse
edit: you're using the wrong shit too, you have onCastSpell with onUse arguments
move it to actions
 
Lua:
function onCastSpell(cid, item, fromPosition, toPosition)
    local level = getPlayerLevel(cid)
    local mana = math.random(level, (level*2))
   
    doPlayerAddMana(cid, mana)
    doSendAnimatedText(getPlayerPosition(cid), '+' .. mana, TEXTCOLOR_PURPLE)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)          
end

This worked, didn't have to move it to actions. Thanks for your help! :)
 
Solution

Similar threads

Back
Top