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

Solved Spell loop...

owned

Excellent OT User
Joined
Nov 9, 2008
Messages
2,001
Solutions
3
Reaction score
563
Location
New York
been having quite the issue with this spell recently, the looping just wont work. I receive an error, thing not found and line 14 attempt to index a boolean value. Lookin for some help, here's the core of the script:

Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 1)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 255)

function onGetFormulaValues(cid, level, maglevel)
    local magTotal, levelTotal = maglevel, level
    return -(levelTotal * 2.6 + magTotal * 4), -(levelTotal * 3.7 + magTotal * 5)
end

setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local function spell()
local targetpos1 = { x=getCreaturePosition(target).x, y=getCreaturePosition(target).y + 1, z=getCreaturePosition(target).z }
local frompos4 = { x=getCreaturePosition(target).x - 1, y=getCreaturePosition(target).y, z=getCreaturePosition(target).z }
doSendDistanceShoot(frompos4, targetpos1, 28)
end

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
    local delay = 100
    local seconds = 0
    local parameters = { cid = cid, var = var, combat = combat }
    repeat
        addEvent(spell, seconds, parameters)
        seconds = seconds + delay
    until seconds == 4000
return true
end

Any help is appreciated. Thanks ahead...
 
I'm not sure, but I think it's something to do with the function doSendDistanceShoot that uses variable targetpos1. Are you sure that this function as the second argument takes 'pos'?
 
Code:
local function spell()
It doesn't have the parameter target which is used in getCreaturePosition(target).
Atm in addEvent you have parameters as parameter, but this is a table with cid, var and combat, which is not used in the function spell.
Code:
addEvent(spell, seconds, target)
Then also add the parameter to the function spell
Code:
local function spell(target)
 
Code:
local function spell()
It doesn't have the parameter target which is used in getCreaturePosition(target).
Atm in addEvent you have parameters as parameter, but this is a table with cid, var and combat, which is not used in the function spell.
Code:
addEvent(spell, seconds, target)
Then also add the parameter to the function spell
Code:
local function spell(target)
Thank you so much worked perfectly. And thanks for explaining it now, i understand where i messed up.
 
Back
Top