• 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 1.X+ spell crashing server? why? 0.4 -> 1.2

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
HI! I have a server 0.4 and i'm changing to server 1.2 (all is version 8.6).
In source 0.4, this works fine, if player use the spell and die, nothing happens... but in 1.2 if player use spell and die, the server crash, have some solution in source files?

obs: the problem inst with the spell script, because it works fine in tfs 0.4
Look this video in tfs 1.2: If i use spell its ok... but if i use the spell and log-out the server crashes.


Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_NONE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 167)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1.2, 1, -1.2, 1)
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, 35)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 132)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -99.2, 2, -80.2, 2)
setCombatParam(combat2, COMBAT_PARAM_HITCOLOR, 35)

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

arr2 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

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

local function onCastSpell1(parameters)
    return isPlayer(parameters.cid) and doCombat(parameters.cid, combat1, parameters.var)
end

local function onCastSpell2(parameters)
    return isPlayer(parameters.cid) and doCombat(parameters.cid, combat2, parameters.var)
end


function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 100, parameters)
addEvent(onCastSpell2, 2300, parameters)
return TRUE
end
 
Last edited:
Why changing server to 1.2 if you still use the old scripts without the advantage of oop classes? Even if there's compatibility layer the 0.x tfs functions are deprecated and shouldn't be used unless you know why you need to use them.
You have crashes because you can't pass directly oop classes to addevent and you probably have disabled "warnUnsafeScripts" in config.lua, you can change "convertUnsafeScripts" to true in config.lua however it'll consume a lot more of cpu for addevents due to conversion but I recommend to stop using the 0.x functions(you'll see performance increase when a lot of player use spells).
 
Your server is crashing because your passing userdata directly without verifying its integrity.

This might solve your issue, not tested.
Lua:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
combat1:setParameter(COMBAT_PARAM_EFFECT, 167)
combat1:setParameter(COMBAT_FORMULA_LEVELMAGIC, -1.2, 1, -1.2, 1)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 132)
combat2:setParameter(COMBAT_FORMULA_LEVELMAGIC, -99.2, 2, -80.2, 2)

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

arr2 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

combat1:setArea(createCombatArea(arr1))
combat2:setArea(createCombatArea(arr2))

local function onCastSpell1(creatureId, var)
    local creature = Creature(creatureId)
    if not creature then
        return true
    end
    return combat1:execute(creature, var)
end

local function onCastSpell2(creatureId, var)
    local creature = Creature(creatureId)
    if not creature then
        return true
    end
    return combat2:execute(creature, var)
end


function onCastSpell(creature, variant)
    addEvent(onCastSpell1, 100, creature:getId(), variant)
    addEvent(onCastSpell2, 2300, creature:getId(), variant)
    return true
end
 
Last edited:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 167)
combat:setArea(arr1)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 132)
combat2:setArea(arr2)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end
function onGetFormulaValues2(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

arr2 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}


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



Try this.
COMBAT_PARAM_HITCOLOR, 35
What is that HITCOLOR?? maybe this crash you server
roriscrave
 
Your server is crashing because your passing userdata directly without verifying its integrity.

This might solve your issue, not tested.
Lua:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
combat1:setParameter(COMBAT_PARAM_EFFECT, 167)
combat1:setParameter(COMBAT_FORMULA_LEVELMAGIC, -1.2, 1, -1.2, 1)
combat1:setParameter(COMBAT_PARAM_HITCOLOR, 35)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 132)
combat2:setParameter(COMBAT_FORMULA_LEVELMAGIC, -99.2, 2, -80.2, 2)
combat2:setParameter(COMBAT_PARAM_HITCOLOR, 35)

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

arr2 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

combat1:setArea(createCombatArea(arr1))
combat2:setArea(createCombatArea(arr2))

local function onCastSpell1(creatureId, var)
    local creature = Creature(creatureId)
    if not creature then
        return true
    end
    return combat1:execute(creature, var)
end

local function onCastSpell2(creatureId, var)
    local creature = Creature(creatureId)
    if not creature then
        return true
    end
    return combat2:execute(creature, var)
end


function onCastSpell(creature, variant)
    addEvent(onCastSpell1, 100, creature:getId(), variant)
    addEvent(onCastSpell2, 2300, creature:getId(), variant)
    return true
end

with this script, i get debug when use the spell, i dont know why


Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 167)
combat:setArea(arr1)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, 132)
combat2:setArea(arr2)

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end
function onGetFormulaValues2(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

arr1 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}

arr2 = {
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 3, 0, 0},
    {0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0}
}


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



Try this.
COMBAT_PARAM_HITCOLOR, 35
What is that HITCOLOR?? maybe this crash you server
roriscrave
and with your script, the server crashes, hit color is a color of the hit
 
Back
Top