TFS 1.X+ ERROR AddEvent() Argument # 3 is unsafe

donnyred

Well-Known Member
Joined
Apr 29, 2009
Messages
15
Reaction score
0
Hi everybody

I need a simple help for this spells....
the truth is that I do not know much about... buy someone can explain me, I'll be grateful.

this is my script.lua

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
combat:setArea(createCombatArea(DYBBUK_AREA1))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 2.5) + (maglevel * 20) + 50
    local max = (level / 2.5) + (maglevel * 18.4) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function llamarSpells(creature, variant)
    local player = Player(creature)
    combat:execute(player.uid, variant)
    --return true
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    addEvent(llamarSpells,0,player.uid, variant)
    return true
    --return combat:execute(creature, variant)
end
and this is the log:

Lua Script Error: [Spell Interface]
data/spells/scripts/Dybbuk/Special_dybbuk_san.lua:eek:nCastSpell
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,388
Reaction score
1,969
why are you using addEvent in the first place if you have the milliseconds set to 0?
just call it normally with
Lua:
llamarSpells(player:getId(), variant)
 
OP
donnyred

donnyred

Well-Known Member
Joined
Apr 29, 2009
Messages
15
Reaction score
0
why are you using addEvent in the first place if you have the milliseconds set to 0?
just call it normally with
Lua:
llamarSpells(player:getId(), variant)
because i will agree more combats but first i want to learn how work this fuction (addevent)

please Vulcan can you be more specific? please :)
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,388
Reaction score
1,969
try this
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
combat:setArea(createCombatArea(DYBBUK_AREA1))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 2.5) + (maglevel * 20) + 50
    local max = (level / 2.5) + (maglevel * 18.4) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function llamarSpells(cid, varid)
    local player = Player(cid)
    if not player then
        return
    end
    local variant = Variant(varid)
    if variant then
        combat:execute(player, variant)
    end
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end
    addEvent(llamarSpells, 1000, player:getId(), variant:getNumber())
    return true
end
 
OP
donnyred

donnyred

Well-Known Member
Joined
Apr 29, 2009
Messages
15
Reaction score
0
try this
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
combat:setArea(createCombatArea(DYBBUK_AREA1))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 2.5) + (maglevel * 20) + 50
    local max = (level / 2.5) + (maglevel * 18.4) + 50
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function llamarSpells(cid, varid)
    local player = Player(cid)
    if not player then
        return
    end
    local variant = Variant(varid)
    if variant then
        combat:execute(player, variant)
    end
end

function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end
    addEvent(llamarSpells, 1000, player:getId(), variant:getNumber())
    return true
end

Woow! thanks thanks! Vulcans...
Now I try add more combats
so
i don't undestand this part: variant:getNumber()
what is variant?

Thanks Again vulcans!
blessings
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,388
Reaction score
1,969
Woow! thanks thanks! Vulcans...
Now I try add more combats
so
i don't undestand this part: variant:getNumber()
what is variant?

Thanks Again vulcans!
blessings
it's just a table that stores a creature id, position, or parameters to the spell
usually when it stores a creature id that's when your spell uses a target like exori hur
it'll store a position if your spell is a ue like exevo gran mas vis
it'll store a string if your spell uses a parameter such as exura sio "playername
 
OP
donnyred

donnyred

Well-Known Member
Joined
Apr 29, 2009
Messages
15
Reaction score
0
:eek: its amazing
Thanks
The script with others combats work perfect
 
Top