0.4
Morning, I know there is a lot of threads talking about the same error, but I haven't found one that helped me.
I made this spell, where after 2 seconds, deals damage on the target. Simple.
The problem is: if the player (or creature) that used the spell cease to exist (logging out or dying), i get the error: (luaGetCreatureTarget) Creature not found
I can't find the real "check" for this, because I'm using a target check, but if they die, it can't check if it has a target.
Morning, I know there is a lot of threads talking about the same error, but I haven't found one that helped me.
I made this spell, where after 2 seconds, deals damage on the target. Simple.
The problem is: if the player (or creature) that used the spell cease to exist (logging out or dying), i get the error: (luaGetCreatureTarget) Creature not found
I can't find the real "check" for this, because I'm using a target check, but if they die, it can't check if it has a target.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onCastSpell(cid, var)
doCreatureSetNoMove(cid, true)
doCombat(cid, combat, var)
doSendAnimatedText(getCreaturePos(cid), "2", 150)
addEvent(function()
if isCreature(cid) then
doSendAnimatedText(getCreaturePos(cid), "1", 150)
doCreatureSetNoMove(cid, false)
end
end, 2000)
addEvent(function()
if getCreatureTarget(cid) ~= 0 and isCreature(cid) then
local target = getCreatureTarget(cid)
local enemypos = getCreaturePosition(target)
local pos = getThingPos(cid)
doSendDistanceShoot(pos, enemypos, 15)
return doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -75, -95, 9)
else
return false
end
end, 2000)
end