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

Lua Creature not found

Hypomania

New Member
Joined
Jan 9, 2016
Messages
20
Reaction score
1
Hi,

I was wondering how to make a version of exori which follows the player for a couple of seconds. Here is my current version (I get the creature not found error):

Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)

local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, 6)
setCombatFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0},
    {0, 1, 2, 1, 0},
    {0, 1, 1, 1, 0},
    {0, 0, 0, 0, 0}
}


local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)
local area3 = createCombatArea(arr3)
setCombatArea(combat1, area1)
setCombatArea(combat2, area1)
setCombatArea(combat3, area1)


function onCastSpell1(parameters)
    doCombat(parameters.cid, parameters.combat1, parameters.var, positionToVariant(getCreaturePosition(cid)))
end

function onCastSpell2(parameters)
    doCombat(parameters.cid, parameters.combat2, parameters.var, positionToVariant(getCreaturePosition(cid)))
end

function onCastSpell3(parameters)
    doCombat(parameters.cid, parameters.combat3, parameters.var, positionToVariant(getCreaturePosition(cid)))
end

function onCastSpell(cid, var) 
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2, combat3 = combat3 }

addEvent(onCastSpell1, 1, parameters) 
addEvent(onCastSpell2, 500, parameters) 
addEvent(onCastSpell3, 1000, parameters) 

return true
end
 
Code:
local intervals = {1, 500, 1000} -- time between execution, also this sets the amount of hits
local combat = {}
local customCombatArea = {}

local area = {
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0},
    {0, 1, 2, 1, 0},
    {0, 1, 1, 1, 0},
    {0, 0, 0, 0, 0}
}

for x = 1, #intervals do
    combat[x] = createCombatObject()
    setCombatParam(combat[x], COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    setCombatParam(combat[x], COMBAT_PARAM_EFFECT, 6)
    setCombatFormula(combat[x], COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)
   
    customCombatArea[x] = createCombatArea(area)
    setCombatArea(combat[x], customCombatArea[x])
end

function onCastSpell(cid, var)
    for n = 1, #intervals do
        addEvent(
            function(cid, combat, var)
                -- is there an isCreature function? hmm
                if isCreature(cid) then
                    doCombat(cid, combat, var, positionToVariant(getCreaturePosition(cid)))
                end
            end,
        intervals[n], cid, combat[n], var
        )
    end
    return true
end
 
Code:
local intervals = {1, 500, 1000} -- time between execution, also this sets the amount of hits
local combat = {}
local customCombatArea = {}

local area = {
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0},
    {0, 1, 2, 1, 0},
    {0, 1, 1, 1, 0},
    {0, 0, 0, 0, 0}
}

for x = 1, #intervals do
    combat[x] = createCombatObject()
    setCombatParam(combat[x], COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    setCombatParam(combat[x], COMBAT_PARAM_EFFECT, 6)
    setCombatFormula(combat[x], COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)
 
    customCombatArea[x] = createCombatArea(area)
    setCombatArea(combat[x], customCombatArea[x])
end

function onCastSpell(cid, var)
    for n = 1, #intervals do
        addEvent(
            function(cid, combat, var)
                -- is there an isCreature function? hmm
                if isCreature(cid) then
                    doCombat(cid, combat, var, positionToVariant(getCreaturePosition(cid)))
                end
            end,
        intervals[n], cid, combat[n], var
        )
    end
    return true
end
Thanks for the response, but it still gives the same error. Also, yes, there is a isCreature(cid) function.

[13/01/2016 18:18:58] Description:
[13/01/2016 18:18:58] (luaDoCombat) Creature not found
 
Code:
local intervals = {1, 500, 1000} -- time between execution, also this sets the amount of hits
local combat = {}
local customCombatArea = {}

local area = {
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0},
    {0, 1, 2, 1, 0},
    {0, 1, 1, 1, 0},
    {0, 0, 0, 0, 0}
}

for x = 1, #intervals do
    combat[x] = createCombatObject()
    setCombatParam(combat[x], COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    setCombatParam(combat[x], COMBAT_PARAM_EFFECT, 6)
    setCombatFormula(combat[x], COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)
   
    customCombatArea[x] = createCombatArea(area)
    setCombatArea(combat[x], customCombatArea[x])
end

function onCastSpell(cid, var)
    for n = 1, #intervals do
        addEvent(
            function(cid, combat)
                -- is there an isCreature function? hmm
                if isCreature(cid) then
                    doCombat(cid, combat, positionToVariant(getCreaturePosition(cid)))
                end
            end,
        intervals[n], cid, combat[n]
        )
    end
    return true
end
 
Code:
local intervals = {1, 500, 1000} -- time between execution, also this sets the amount of hits
local combat = {}
local customCombatArea = {}

local area = {
    {0, 0, 0, 0, 0},
    {0, 1, 1, 1, 0},
    {0, 1, 2, 1, 0},
    {0, 1, 1, 1, 0},
    {0, 0, 0, 0, 0}
}

for x = 1, #intervals do
    combat[x] = createCombatObject()
    setCombatParam(combat[x], COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    setCombatParam(combat[x], COMBAT_PARAM_EFFECT, 6)
    setCombatFormula(combat[x], COMBAT_FORMULA_LEVELMAGIC, -0.7, -30, -0.7, -0)
  
    customCombatArea[x] = createCombatArea(area)
    setCombatArea(combat[x], customCombatArea[x])
end

function onCastSpell(cid, var)
    for n = 1, #intervals do
        addEvent(
            function(cid, combat)
                -- is there an isCreature function? hmm
                if isCreature(cid) then
                    doCombat(cid, combat, positionToVariant(getCreaturePosition(cid)))
                end
            end,
        intervals[n], cid, combat[n]
        )
    end
    return true
end
Wow, that seems to work perfectly, thank you very much! :)
 
Could you also please explain why it didn't work before?
There are only 3 parameters in doCombat, cid, combat & var, initially we had 4, since positionToVariant(getCreaturePosition(cid)) was the intended value to pass as an argument to doCombat, var needed to be replaced with the value returned from positionToVariant, so that it may be passed the proper data to doCombat.

Variant is a table of position and maybe other data, run a for loop over it to see what values it holds, sorry i don't write or test the code using a server :(
 
Last edited:
There are only 3 parameters in doCombat, cid, combat & var, initially we had 4, since positionToVariant(getCreaturePosition(cid)) was the intended value to pass as an argument to doCombat, var needed to be replaced with the value returned from positionToVariant, so that it may be passed the proper data to doCombat.

Variant is a table of position and maybe other data, run a for loop over it to see what values it holds, sorry i don't write or test the code using a server :(
Thank you a lot, that was really useful :)
 
Back
Top