Helliot1
Owner of Empire Online
- Joined
- Jul 26, 2017
- Messages
- 315
- Solutions
- 1
- Reaction score
- 58
Hello, I have a problem here, I saw a spell that teleport you to a player that are in screen, but I'm using OTX3, and get a error when I use this spell
How I can fix it ??
This is the Script
How I can fix it ??
Lua:
Lua Script Error: [Spell Interface]
data/spells/scripts/barbarian/blind rush.lua:onCastSpell
data/spells/scripts/barbarian/blind rush.lua:30: attempt to call global 'getPosByDir' (a nil value)
stack traceback:
[C]: in function 'getPosByDir'
data/spells/scripts/barbarian/blind rush.lua:30: in function <data/spells/scripts/barbarian/blind rush.lua:10>
This is the Script
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function getDamage(cid, level, magic)
return -(level * 5 + magic * 12), -(level * 5 + magic * 12 + 55)
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "getDamage")
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
if target <= 1 then
doPlayerSendCancel(cid, "You need a target.")
return false
end
if not isSightClear(getThingPos(cid), getThingPos(target), false) then
doPlayerSendCancel(cid, "You can't reach that place.")
return false
end
local targetPos = getThingPos(target)
local directions = {0, 1, 2, 3, 4, 5, 6, 7}
local teleportPos = {}
for _ = 1, #directions do
local random = math.random(#directions)
local dir = directions[random]
table.remove(directions, random)
local newPos = getPosByDir(targetPos, dir)
if doTileQueryAdd(cid, newPos, 0, false) == 1 then
teleportPos = newPos
break
end
end
if teleportPos.x and doTileQueryAdd(cid, teleportPos, 0, false) == 1 then
doCombat(cid, combat, var)
doTeleportThing(cid, teleportPos, false)
return true
end
doPlayerSendCancel(cid, "You cannot teleport there.")
return false
end