local config = {
tilesLimitToTeleport = 8, -- if summon is X sqm away it will be teleported to owner
interval = 5, -- checks summons positions every X seconds
teleportMonsterSummonsToo = true -- not work if your monsters havent registered this creaturescript
}
function onThink(cid, interval)
if teleportMonsterSummonsToo == true or isMonster(cid) == false then
local summons = getCreatureSummons(cid)
if(not summons or next(summons) == nil) then
return false
end
local pos = getThingPos(cid)
if(getTilePzInfo(pos)) == true then
return false
end
for _, sid in pairs(summons) do
local summonPos = getThingPos(sid)
if(getDistanceBetween(pos, summonPos) > config.tilesLimitToTeleport or pos.z ~= summonPos.z) then
doTeleportThing(sid, pos)
doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(summonPos, CONST_ME_MAGIC_RED)
end
end
end
return true
end