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

Linux error when using this spell

JonatasLucas

New Member
Joined
Jun 12, 2013
Messages
116
Reaction score
3
so when we use the explosive trap magic in my OTServ is giving error and it is entering into the PZ

4011551c787a61bb91de76c8ad5319658b3a72ae.png


armadilha.lua
Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_AGGRESSIVE, true)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat1, COMBAT_PARAM_CREATEITEM, 1497)


local combat2 = createCombatObject()
function spellCallback2(param)
if param.count > 0 or math.random(0, 1) == 1 then
doSendMagicEffect(param.pos, CONST_ME_EXPLOSIONHIT)
doAreaCombatHealth(param.cid, COMBAT_PHYSICALDAMAGE, param.pos, 0, -300, -1000, CONST_ME_BLOCKHIT)
end

if(param.count < 5) then
param.count = param.count + 1
addEvent(spellCallback2, math.random(1000, 1500), param)
end
end

function onTargetTile(cid, pos)
local param = {}
param.cid = cid
param.pos = pos
param.count = 0
spellCallback2(param)
end

setCombatCallback(combat2, CALLBACK_PARAM_TARGETTILE, "onTargetTile")


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

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

local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)

local area2 = createCombatArea(arr2)
setCombatArea(combat2, area2)

local function onCastSpell1(parameters)
doCombat(parameters.cid, parameters.combat1, parameters.var)
end
local function onCastSpell2(parameters)
doCombat(parameters.cid, parameters.combat2, parameters.var)
end

function onCastSpell(cid, var) 
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2 }
addEvent(doCombat, 0, cid, combat1, var)
addEvent(doCombat, 0, cid, combat2, var)
return TRUE
end
 
Code:
local arr1 = {
    { 1, 1, 1, 1, 1, },
    { 1, 0, 0, 0, 1, },
    { 1, 0, 3, 0, 1, },
    { 1, 0, 0, 0, 1, },
    { 1, 1, 1, 1, 1, },
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, true)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_CREATEITEM, 1497)
combat:setArea(createCombatArea(arr1))

local function spellCallback(cid, position, count)
    if count > 0 or math.random(0, 1) == 1 then
        position:sendMagicEffect(CONST_ME_EXPLOSIONHIT)
        doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, position, 0, -300, -1000, CONST_ME_BLOCKHIT)
    end

    if(count < 5) then
        count = count + 1
        addEvent(
            function (cid, position, count)
                if(Player(cid)) then
                    spellCallback(cid, position, count)
                end
            end, math.random(1000, 1500), cid, position, count
        )
    end
end

function onTargetTile(creature, position)
    spellCallback(creature:getId(), position, 0)
end

local combat2 = Combat()
combat2:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
combat2:setArea(createCombatArea(AREA_SQUARE1X1))

function onCastSpell(creature, var)
    combat:execute(creature, var)
    combat2:execute(creature, var)
    return true
end

A tip would be to rewrite your other spells aswell.
And do try to remember this issue, you are actually sending userdata to a scheduled event when you should send the creature id.
You can look at how I did it with the addEvent function and compare it what you posted.
 
Make sure you change the codes i put in there to the right things, I dont use these script systems so I just put what I think they are.

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

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, true)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_CREATEITEM, 1497)
combat:setArea(createCombatArea(arr1))

local function spellCallback(cid, position, count)
    if count > 0 or math.random(0, 1) == 1 then
        position:sendMagicEffect(CONST_ME_EXPLOSIONHIT)
        doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, position, 0, -300, -1000, CONST_ME_BLOCKHIT)
    end

    if(count < 5) then
        count = count + 1
        addEvent(
            function (cid, position, count)
                if(Player(cid)) then
                    spellCallback(cid, position, count)
                end
            end, math.random(1000, 1500), cid, position, count
        )
    end
end

function onTargetTile(creature, position)
-----------------------------------------------------------------------------------------------
--edit this with the write coding, I am not sure about codes in TFS 0.4+
    if tile:PzInfo(position) then
    return false
    end
--------------------------------------------------------------------------------------------------
    spellCallback(creature:getId(), position, 0)
end

local combat2 = Combat()
combat2:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
 
The reason your original spell hit in pz is because you just created a combat object without any parameters (speaking of combat2). Try adding COMBAT_PHYSICALDAMAGE and/or AGGRESIVE to prevent it from hitting in pz.
 
Back
Top