• 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 Push spell not working (TFS 1.3) (single target)

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hello guys, I found this script here on the forum, but the spell ain't working:
The spell should push any monster or player for x sqm.

local creaturePushInfo = {}

local function resetCreaturePushInfo(cid)
creaturePushInfo[cid] = nil
end

local function doPushCreature(target, cid)
if target > 0 then
if not isInArray(creaturePushInfo[cid], target) then
if not isNpc(target) then
local position = getThingPosition(cid)
local fromPosition = getThingPosition(target)
local x = ((fromPosition.x - position.x) < 0 and -1 or ((fromPosition.x - position.x) == 0 and 0 or 1))
local y = ((fromPosition.y - position.y) < 0 and -1 or ((fromPosition.y - position.y) == 0 and 0 or 1))
local toPosition = {x = fromPosition.x + x, y = fromPosition.y + y, z = fromPosition.z}
if doTileQueryAdd(target, toPosition) == 1 and getTileInfo(toPosition).house == false then
table.insert(creaturePushInfo[cid], target)
doTeleportThing(target, toPosition, true)
end
end
end
end
end

local spell = {}
spell.config = {
[3] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}
},
[2] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
},
[1] = {
damageType = 1,
areaEffect = 2,
area = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
}
}
}

spell.combats = {}
for _, config in ipairs(spell.config) do
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, config.damageType)
setCombatParam(combat, COMBAT_PARAM_EFFECT, config.areaEffect)
function onTargetCreature(cid, target)
doPushCreature(target, cid)
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")
setCombatArea(combat, createCombatArea(config.area))
table.insert(spell.combats, combat)
end

function onCastSpell(cid, var)
creaturePushInfo[cid] = {}
addEvent(resetCreaturePushInfo, 500, cid.uid)
for n = 1, #spell.combats do
addEvent(doCombat, (n * 150) - 150, cid.uid, spell.combats[n], var)
end
return true
end
That the error it shows in TFS:

Lua Script Error: [Spell Interface]
in callback: data/spells/scripts/attack/push.lua:eek:nTargetCreature
(Unknown scriptfile)
data/spells/scripts/attack/push.lua:8: attempt to compare number with userdata

Also, how do I put this in single target?
 
Back
Top