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

Lua setCombatCallback() is overwriting itself in two script files

ddl

New Member
Joined
Jan 4, 2013
Messages
3
Reaction score
0
This is my code:
Code:
spells.xml
<!-- Custom Spells -->
    <instant name="Growth" words="growth" lvl="1" manapercent="0" cooldown="0" needlearn="0" script="custom/growth.lua" />
    <instant name="Fire Ring" words="fire ring" lvl="1" manapercent="0" cooldown="0" needlearn="0" script="custom/fire ring.lua" />
Code:
fire ring.lua
function onTargetTile(cid, pos)
   ...
   code
   ...
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
Code:
growth.lua
function onTargetTileGrowth(cid, pos)
   ...
   code
   ...
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTileGrowth")



Growth is using CombatCallback from fire ring.lua, because it's loaded after growth.lua. How to baypass it?
 
Code:
local combat = {}

     combat[1] = createCombatObject()
 

local arr1 = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
}


local arrs = {arr1}

     setCombatArea(combat[1], createCombatArea(arrs[1]))


function spellCallback(param)
    if Creature(param.cid) then
        if param.count > 0 or math.random(0, 1) == 1 and Creature(param.cid) then
            (param.pos):sendMagicEffect(81)
            doAreaCombatHealth(param.cid, COMBAT_FIREDAMAGE, param.pos, 0, -100, -100, 7)
        end

        if(param.count < 1) then
            param.count = param.count + 1
            addEvent(spellCallback, math.random(1000, 6000), param)
        end
    end
end

function onTargetTile(creature, pos)
    local param = {}
    param.cid = creature:getId()
    param.pos = pos
    param.count = 0
    spellCallback(param)
end

setCombatCallback(combat[1], CALLBACK_PARAM_TARGETTILE, "onTargetTile")




function onCastSpell(creature, var)

    local prevOutfit = creature:getOutfit()
    local target = creature:getTarget()
    local newOutfit = {lookType = 5}


    if prevOutfit.lookType == 2 and target ~= nil then
        addEvent(function(cid, prev)
            local creature = Creature(cid)
            if not creature then
                return
            end
            creature:setOutfit(prev)
        end, 400, creature:getId(), prevOutfit)

        creature:setOutfit(newOutfit)
           
        if not target then
            return
        end
   
        local function A()
   
        local befOutfit = creature:getOutfit()
        local newOutfitt = {lookType = 6}
   
        if befOutfit.lookType == 2 then
   
        creature:setOutfit(newOutfitt)   
        end
        end   
   
        addEvent(A, 450)
       
        addEvent(doCombat, 1 * 2000, creature, combat[1], var)
   
        if target:getOutfit().lookType == 2 then
            target:addCondition(condition)
        end
          if target:getOutfit().lookType == 8 then
            target:addCondition(condition1)
        end
        if target:getOutfit().lookType == 19 then
            target:addCondition(condition2)
        end
   
        if target:getOutfit().lookType == 28 then
            target:addCondition(condition3)
        end
           

local function C()

        local newOutfit3 = {lookType = 2}
        creature:setOutfit(newOutfit3)
          
        end
   
        addEvent(C, 7000)   
   
        return combat[1]:execute(creature, var)
    else
    return combat[1]:execute(creature, var)
    end
end

I did this script, got no error, but if i logout while the effect is running my server crash.
 
Back
Top