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

TFS 0.X Spell Error

boxxer321

Well-Known Member
Joined
Nov 5, 2011
Messages
118
Reaction score
59
Hi everyone, this spell has a kind of error that I can not fix, can you help me?

erro:
[18:6:45.812] [Error - Spell Interface]
[18:6:45.821] data/spells/scripts/attack/exevo gran mas cold.lua:eek:nCastSpell
[18:6:45.853] Description:
[18:6:45.861] data/spells/scripts/attack/exevo gran mas cold.lua:23: bad argument #1 to 'random' (interval is empty)
[18:6:45.881] stack traceback:
[18:6:45.890] [C]: in function 'random'
[18:6:45.914] data/spells/scripts/attack/exevo gran mas cold.lua:23: in function <data/spells/scripts/attack/exevo gran mas cold.lua:5>

script:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -50.0, -1500, -30.0, -1800)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 10569) == 1 then
doSendAnimatedText((getCreaturePosition(cid)), "Socorro!", 255)
doSendMagicEffect(getCreaturePosition(cid), 19)
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return false
end

if getPlayerStorageValue(cid, 23066) < os.time () then
setPlayerStorageValue(cid, 23066, 9) -- 9 = 9 segundos
local cooldown = 10
local playerpos = getCreaturePosition(cid)
local target = getCreatureTarget(cid)
local trapos = getCreaturePosition(target)
local level = getPlayerMagLevel(cid)
local numero1 = (level*99.99) -- Dano Mínimo
local numero2 = (level*99.99) -- Dano Máximo
for i = numero1, numero2 do
levelz = (math.random(numero2))
end

function mascold(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "CD: Exevo Gran Mas Cold.")
end

mana1 = (10*getCreatureMaxMana(cid)/100 +300)
mana = math.ceil(mana1)
doPlayerAddMana(cid,mana)
doCreatureAddMana(target, -levelz)
doSendAnimatedText(trapos, levelz, 29)
doCreatureAddMana(cid, levelz)
doCreatureAddMana(cid, -0) -- Quanto Vai Gastar de Mana
doSendMagicEffect(trapos, 41)
doSendMagicEffect(playerpos, 41)
doSendAnimatedText(getThingPos(cid),"Drainage!",29)
doSendDistanceShoot(trapos, playerpos, 28)

if exhaustion.check(cid, 23066) == false then
exhaustion.set(cid, 23066, cooldown)
addEvent(mascold, cooldown*1000, cid)
return doCombat(cid, combat, var)

else
doSendMagicEffect(getCreaturePosition(cid), 2)
doPlayerSendCancel(cid, "Golpe em cooldown por " ..exhaustion.get(cid, 23066).." segundos")
return false
end
return doCombat(cid, combat, var)
end
end
 
Please use code tag for readability.

b6311d3dc6700cc90e021d018856619a.png
 
Hi everyone, this spell has a kind of error that I can not fix, can you help me?

erro:


script:
It's not working because numero1 and numero2 are floats instead of integers and math.random won't work with it unless its in an integer.
Change them to:

Lua:
local numero1 = math.ceil(level*99.99)
local numero2 = math.ceil(level*99.99)

Tbh tho, this script is so dirty, you're probably better off having it rewritten. Explain what you want and and someone can probably write a better one for you.
 
It's not working because numero1 and numero2 are floats instead of integers and math.random won't work with it unless its in an integer.
Change them to:

Lua:
local numero1 = math.ceil(level*99.99)
local numero2 = math.ceil(level*99.99)

Tbh tho, this script is so dirty, you're probably better off having it rewritten.

Could you rewrite it for me? im not so good with scripts!

and not work what you say:

[21:20:24.632] [Error - Spell Interface]
[21:20:24.639] data/spells/scripts/attack/exevo gran mas cold.lua:eek:nCastSpell
[21:20:24.647] Description:
[21:20:24.650] data/spells/scripts/attack/exevo gran mas cold.lua:34: attempt to perform arithmetic on global 'levelz' (a nil value)
[21:20:24.661] stack traceback:
[21:20:24.667] data/spells/scripts/attack/exevo gran mas cold.lua:34: in function <data/spells/scripts/attack/exevo gran mas cold.lua:5>
 
Could you rewrite it for me? im not so good with scripts!

and not work what you say:

[21:20:24.632] [Error - Spell Interface]
[21:20:24.639] data/spells/scripts/attack/exevo gran mas cold.lua:eek:nCastSpell
[21:20:24.647] Description:
[21:20:24.650] data/spells/scripts/attack/exevo gran mas cold.lua:34: attempt to perform arithmetic on global 'levelz' (a nil value)
[21:20:24.661] stack traceback:
[21:20:24.667] data/spells/scripts/attack/exevo gran mas cold.lua:34: in function <data/spells/scripts/attack/exevo gran mas cold.lua:5>
Explain what you want
 
is an attack for druid, that of a strong attack and heal 20-25% of the mana
Seems counter intuitive, why not just use 20-25% less mana to cast spell? It's essentially the same thing.

But this should work, untested tho, not sure how exhaustion works in old tfs but I tried.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -50.0, -1500, -30.0, -1800)

local function addManaBonus(cid)
    if not isPlayer(cid) then
        return
    end
    local mana = getPlayerMaxMana(cid)
    local mana_gain = math.random(math.ceil(mana * .20), math.ceil(mana * .25))
 
    doPlayerAddMana(cid, mana_gain)
end

function onCastSpell(cid, var)
    if exhaustion.check(cid, 23066) == false then
        exhaustion.set(cid, 23066, 10)
        addManaBonus(cid)
        return doCombat(cid, combat, var)
    else
        doSendMagicEffect(getCreaturePosition(cid), 2)
        doPlayerSendCancel(cid, "You are exhausted.")
        return false
    end
end
 
Seems counter intuitive, why not just use 20-25% less mana to cast spell? It's essentially the same thing.

But this should work, untested tho, not sure how exhaustion works in old tfs but I tried.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -50.0, -1500, -30.0, -1800)

local function addManaBonus(cid)
    if not isPlayer(cid) then
        return
    end
    local mana = getPlayerMaxMana(cid)
    local mana_gain = math.random(math.ceil(mana * .20), math.ceil(mana * .25))
 
    doPlayerAddMana(cid, mana_gain)
end

function onCastSpell(cid, var)
    if exhaustion.check(cid, 23066) == false then
        exhaustion.set(cid, 23066, 10)
        addManaBonus(cid)
        return doCombat(cid, combat, var)
    else
        doSendMagicEffect(getCreaturePosition(cid), 2)
        doPlayerSendCancel(cid, "You are exhausted.")
        return false
    end
end
I don't think you quite thought it through fully.

Example:
mana cost = 100
damage dealt = 500

25% less mana = 25.
25% of 500 = 125 mana.

So it's a pretty significant difference.
 
I don't think you quite thought it through fully.

Example:
mana cost = 100
damage dealt = 500

25% less mana = 25.
25% of 500 = 125 mana.

So it's a pretty significant difference.
Yeah you're right it's not the same, but you'd be gaining mana from that one. I was thinking he wanted 25% of max mana too.

If there was a maximum cap in how much you can gain it could work. But I still feel adding mana with a spell is weird.

Either way idk wtf he wants tbh, twisting arms to get an explanation and it ended up being a vague one.
 
Last edited:
Back
Top