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

Solved addEvent and creature death error

dami1310

◄ Unidentified ►
Joined
Jan 27, 2013
Messages
732
Solutions
12
Reaction score
664
Location
Poland
First of all: I use tfs 0.3.6 for 8.60.
Yeah, I know that there is downgraded 1.3, but this is not what the thread is about so please don't talk about it.
Now let's get to the topic.
I am using a spell with addEvent to stop creature from moving for x time, but...
Code:
function onTargetCreature(cid, target)
local t = 10000
    doCreatureSetNoMove(target, true)
    addEvent(doCreatureSetNoMove, t, target, false)
end
When the target dies. There is no creature to find and obviously error pops up in console.
Code:
[Error - Spell Interface]
In a timer event called from:
(Unknown script file)
Description:
(luaDoCreatureSetNoMove) Creature not found
And I am here to ask if there is any way to prevent that from happening. I mean I can just ignore it, but if it's possible then I would rather do that.
 
Solution
Lua:
function onTargetCreature(cid, target)
    local function freeze(target)
        if isMonster(target) then
            doCreatureSetNoMove(target, true)
        else
            return false
        end
    end
    local t = 10000
    doCreatureSetNoMove(target, true)
    addEvent(freeze, t, target.uid, false)
end

I don't know 0.3.6 function names of the top of my head, so im 50/50 on this.
Give it a try.
Try this
Lua:
function onTargetCreature(cid, target)
local t = 10000
if (isMonster(target) == TRUE) then
    doCreatureSetNoMove(target, true)
    addEvent(doCreatureSetNoMove, t, target, false)
end
end
 
Lua:
function onTargetCreature(cid, target)
    local function freeze(target)
        if isMonster(target) then
            doCreatureSetNoMove(target, true)
        else
            return false
        end
    end
    local t = 10000
    doCreatureSetNoMove(target, true)
    addEvent(freeze, t, target.uid, false)
end

I don't know 0.3.6 function names of the top of my head, so im 50/50 on this.
Give it a try.
 
Last edited:
Solution
Lua:
function onTargetCreature(cid, target)
    local function freeze(target)
        if not isMonster(target) then
            return false
        else
            doCreatureSetNoMove(target, true)
        end
    end
    local t = 10000
    doCreatureSetNoMove(target, true)
    addEvent(freeze, t, target.uid, false)
end

I don't know 0.3.6 function names of the top of my head, so im 50/50 on this.
Give it a try.
Worked perfectly, thanks mate.
 
Back
Top