• 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!

problem on teleport summon script

wafuboe

Active Member
Joined
Dec 24, 2010
Messages
884
Solutions
2
Reaction score
26
Hello i got this script, its supposed to teleport your summon to your location if it falls behind but i found this error in console.

Im using tfs 1.3, i think the script was from other tfs 1.2server i had..

i got this error on console

5vn383.png


Code:
function onThink(creature, interval)
    local maxDistance = 7
    local owner = creature:getMaster()
    local petPosition = creature:getPosition()
    local ownerPosition = owner:getPosition()
    if petPosition.z ~= ownerPosition.z or ownerPosition:getDistance(petPosition) >= maxDistance then
        petPosition:sendMagicEffect(CONST_ME_TELEPORT)
        creature:teleportTo(ownerPosition)
        creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
Solution
LUA:
local distFromMaster = 7

function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        local playerPos = player:getPosition()
        if not Tile(playerPos):hasFlag(TILESTATE_PROTECTIONZONE) then
            local summons = player:getSummons()
            if #summons ~= 0 then
                for i = 1, #summons do
                    local summon = summons[i]
                    local summonPos = summon:getPosition()
                    if summonPos.z ~= playerPos.z or summonPos:getDistance(playerPos) > distFromMaster then
                        summon:teleportTo(playerPos)
                        summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    end
                end...
LUA:
function onThink(creature, interval)
    local maxDistance = 7
    local owner = creature:getMaster()
    if not owner then
        return true
    end
    local petPosition = creature:getPosition()
    local ownerPosition = owner:getPosition()
    if petPosition.z ~= ownerPosition.z or ownerPosition:getDistance(petPosition) >= maxDistance then
        petPosition:sendMagicEffect(CONST_ME_TELEPORT)
        creature:teleportTo(ownerPosition)
        creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end
 
LUA:
function onThink(creature, interval)
    local maxDistance = 7
    local owner = creature:getMaster()
    if not owner then
        return true
    end
    local petPosition = creature:getPosition()
    local ownerPosition = owner:getPosition()
    if petPosition.z ~= ownerPosition.z or ownerPosition:getDistance(petPosition) >= maxDistance then
        petPosition:sendMagicEffect(CONST_ME_TELEPORT)
        creature:teleportTo(ownerPosition)
        creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    end
    return true
end

i got this error on console

b5imug.png
 
LUA:
local distFromMaster = 7

function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        local playerPos = player:getPosition()
        if not Tile(playerPos):hasFlag(TILESTATE_PROTECTIONZONE) then
            local summons = player:getSummons()
            if #summons ~= 0 then
                for i = 1, #summons do
                    local summon = summons[i]
                    local summonPos = summon:getPosition()
                    if summonPos.z ~= playerPos.z or summonPos:getDistance(playerPos) > distFromMaster then
                        summon:teleportTo(playerPos)
                        summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end
 
Solution
Thanks both of you :)
LUA:
local distFromMaster = 7

function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        local playerPos = player:getPosition()
        if not Tile(playerPos):hasFlag(TILESTATE_PROTECTIONZONE) then
            local summons = player:getSummons()
            if #summons ~= 0 then
                for i = 1, #summons do
                    local summon = summons[i]
                    local summonPos = summon:getPosition()
                    if summonPos.z ~= playerPos.z or summonPos:getDistance(playerPos) > distFromMaster then
                        summon:teleportTo(playerPos)
                        summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end
impossible, you sure that's your whole script file?
 
Back
Top