• 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 [TFS 1.2] addEvent with userdata

Shitobu

displays under your name in your posts.
Joined
Apr 24, 2016
Messages
25
Reaction score
1
Code:
function onCastSpell(creature, variant)

    combat:execute(creature, variant)
    addEvent(combat:execute, 1000, creature, variant)
    return true
end

I'm trying to do something like that, so I could use a lot of effects on spells.
Sadly, something is going wrong and I can't work around it.
On console, the error is "function on addEvent line expects arguments near ',' "
Can someone help me? ;_;
 
if I'm not wrong the addEvent only works calling functions
Code:
local function fucktion (combat, creature, variant)
     combat:execute(creture, variant) 
end
  function onCastSpell(creature, variant)

   combat:execute(creature, variant)
    addEvent(funcktion, 1000, combat, creature, variant)
    return true
end
if does not work will not impress me, did this drug now without the knowledge of the complete script, etc., but I tried to show the form that can be performed in the call addEvent using function.
 
Thanks for the answer, silveralol!
Somehow it indeed worked, but it sends an error on console saying the fourth argument of addEvent is unsafe. (probably creature)
I heard you can`t really use userdatas on addEvent... Is it the case?
If you can`t work with userdata on addEvent, how am I supposed to work around? D=
 
Code:
local function doCastSpell(combat, cid, variant)
    local creature = Creature(cid)
    if creature ~= nil then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(doCastSpell, 1000, combat, creature:getId(), variant)
    return true
end

Like that?
 
Code:
local function doCastSpell(combat, cid, variant)
    local creature = Creature(cid)
    if creature ~= nil then
        combat:execute(creature, variant)
    end
end

function onCastSpell(creature, variant)
    combat:execute(creature, variant)
    addEvent(doCastSpell, 1000, combat, creature:getId(), variant)
    return true
end

Like that?
HOLY. FUCK.
It did work. But now it's saying "combat" (addEvent param) is unsafe. Wtf is wrong with it?


@Xeraphus I tried that. Didn't work :<




@Edit
Ouch, it works fine now and I did nothing. No idea why though.
If I end up with any error I'm gonna back here. But till now @Madzix code works completely fine.
Thanks guys!
 
HOLY. FUCK.
It did work. But now it's saying "combat" (addEvent param) is unsafe. Wtf is wrong with it?


@Xeraphus I tried that. Didn't work :<




@Edit
Ouch, it works fine now and I did nothing. No idea why though.
If I end up with any error I'm gonna back here. But till now @Madzix code works completely fine.
Thanks guys!
yeah i forgot about your question and just read combat:execute in one of the scripts and showed how to use it without :
 
Back
Top