• 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 (LuaInterface::luaGetThingPosition) Thing not found [OTX2] [TFS 0.3.6]

Rankret

New Member
Joined
Apr 14, 2023
Messages
13
Reaction score
0
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_DARKPURPLE)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -4.5, -800, -2.0, -900)
local function onCastSpell1(cid, var)
local pos = getCreaturePosition(cid)
local position1 = {x=getThingPosition(getCreatureTarget(cid)).x-1, y=getThingPosition(getCreatureTarget(cid)).y-1, z=getThingPosition(getCreatureTarget(cid)).z}
doSendMagicEffect(position1, 46)
local position2 = {x=getThingPosition(getCreatureTarget(cid)).x+2, y=getThingPosition(getCreatureTarget(cid)).y+2, z=getThingPosition(getCreatureTarget(cid)).z}
doSendMagicEffect(position2, 418)
return doCombat(cid, combat1, var)
end
 
function onCastSpell(cid, var)
local waittime = 2 -- Tempo de exhaustion
local storage = 8222
if exhaustion.check(cid, storage) then
doPlayerSendChannelMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde ".. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
return false
end
for k = 1, 2 do
    addEvent(function()
        if isCreature(cid) then
            addEvent(onCastSpell1, 100, cid, var)
        end
    end, 1 + ((k-1) * 600))
end
exhaustion.set(cid, storage, waittime)
return true
end

Code:
[Error - Spell Interface]
In a timer event called from:
data/spells/scripts/personagem/sasuke/7.lua:onCastSpell
Description:
(LuaInterface::luaGetThingPosition) Thing not found

[Error - Spell Interface]
In a timer event called from:
data/spells/scripts/personagem/sasuke/7.lua:onCastSpell
Description:
data/spells/scripts/personagem/sasuke/7.lua:8: attempt to index a boolean value
stack traceback:
        data/spells/scripts/personagem/sasuke/7.lua:8: in function <data/spells/scripts/personagem/sasuke/7.lua:6>
 
There's no guarantee that the player has a target.
Need to check if the target exists before using it.

Lua:
local target = getCreatureTarget(cid)
if isCreature(target) then
    -- do position stuff
    -- send magic effect to the position
end
 
Lua:
f
función local onCastSpell1(cid, var)
local target = getCreatureTarget(cid)
if isCreature(target) then    
local pos = getCreaturePosition(cid)
local position1 = {x=getThingPosition(getCreatureTarget(cid)).x+1, y=getThingPosition(getCreatureTarget(cid)).y, z=getThingPosition(getCreatureTarget(cid)).z}
doSendMagicEffect(posición1, 79)
local positionME = {x=getPlayerPosition(cid).x+1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
doSendMagicEffect(posiciónME, 416)
return doCombat(cid, combat1, var)
fin
fin

En OnCastSpell?
 
Last edited:
Back
Top