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

TFS 1.X+ Destenation not work on teleport create.

OTcreator

Well-Known Member
Joined
Feb 14, 2022
Messages
482
Solutions
1
Reaction score
53
Hello!
All working good, but teleport not have destenation toPos.
I stand on teleport and nothing.

Whats wrong?

LUA:
function onKill(creature, target)
    local player = creature:isPlayer()
    if not player then
        return true
    end
    
    local pythius = target:isMonster()
    if not pythius then
        return true
    end
    
    local function removal(position)
        local teleport = Tile(position):getItemById(1387)
        if teleport then
            teleport:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
        return true
    end

    local tpPos = Position(544,467,13)
    local toPos = Position(439,481,13)
    local timeToRemove = 30
    
    if target:getName():lower() == "pythius the rotten" then
        local position = tpPos
        local teleport = Game.createItem(1387, 1, tpPos)
         if teleport:isTeleport() then
                teleport:setDestination(toPos)
        end
            creature:say("You have defeated Pythius The Rotten!\nEnter into teleport. It will disappear in thirty seconds.", TALKTYPE_MONSTER_SAY, false, 0 ,tpPos)
            addEvent(removal, timeToRemove * 1000, position)
        end
    return true
end
 
Solution
Hello!
All working good, but teleport not have destenation toPos.
I stand on teleport and nothing.

Whats wrong?

LUA:
function onKill(creature, target)
    local player = creature:isPlayer()
    if not player then
        return true
    end
 
    local pythius = target:isMonster()
    if not pythius then
        return true
    end
 
    local function removal(position)
        local teleport = Tile(position):getItemById(1387)
        if teleport then
            teleport:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
        return true
    end

    local tpPos = Position(544,467,13)
    local toPos = Position(439,481,13)
    local timeToRemove = 30
 
    if target:getName():lower() == "pythius the rotten"...
LUA:
function onKill(creature, target)
    local player = creature:isPlayer()
    if not player then
        return true
    end
    
    local pythius = target:isMonster()
    if not pythius then
        return true
    end
    
    local function removal(position)
        local teleport = Tile(position):getItemById(1387)
        if teleport then
            teleport:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
        return true
    end

    local tpPos = Position(544, 467, 13)
    local toPos = Position(439, 481, 13)
    local timeToRemove = 30
    
    if target:getName():lower() == "pythius the rotten" then
        local position = tpPos
        local teleport = Game.createItem(1387, 1, tpPos)
        
        if teleport:isTeleport() then
            teleport:setDestination(toPos)
            creature:say("You have defeated Pythius The Rotten!\nEnter into the teleport. It will disappear in thirty seconds.", TALKTYPE_MONSTER_SAY, false, 0, tpPos)
            addEvent(removal, timeToRemove * 1000, tpPos)
        end
    end
    
    return true
end
 
Hello!
All working good, but teleport not have destenation toPos.
I stand on teleport and nothing.

Whats wrong?

LUA:
function onKill(creature, target)
    local player = creature:isPlayer()
    if not player then
        return true
    end
 
    local pythius = target:isMonster()
    if not pythius then
        return true
    end
 
    local function removal(position)
        local teleport = Tile(position):getItemById(1387)
        if teleport then
            teleport:remove()
            position:sendMagicEffect(CONST_ME_POFF)
        end
        return true
    end

    local tpPos = Position(544,467,13)
    local toPos = Position(439,481,13)
    local timeToRemove = 30
 
    if target:getName():lower() == "pythius the rotten" then
        local position = tpPos
        local teleport = Game.createItem(1387, 1, tpPos)
         if teleport:isTeleport() then
                teleport:setDestination(toPos)
        end
            creature:say("You have defeated Pythius The Rotten!\nEnter into teleport. It will disappear in thirty seconds.", TALKTYPE_MONSTER_SAY, false, 0 ,tpPos)
            addEvent(removal, timeToRemove * 1000, position)
        end
    return true
end

Tested your script, its working for me
You sure u got right position?
Add the local function always above the main function
Local variable aswell if its possible here a example + easier to read ( if u ask me )
LUA:
local config = {
    monsterName = "rotworm",
    spawnTeleport = Position(1000, 1000, 7),
    changePosition = Position(1000, 1013, 7),
    timeToRemove = 5,
}

local function removal(position)
    local teleport = Tile(position):getItemById(1387)
    if teleport then
        teleport:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

function onKill(creature, target)
    if not creature:isPlayer() or not target:isMonster() then
        return true
    end
 
    if target:getName():lower() == config.monsterName then
        local teleport = Game.createItem(1387, 1, config.spawnTeleport)
        if teleport:isTeleport() then
            teleport:setDestination(config.changePosition)
        end
        creature:say("You have defeated Pythius The Rotten!\nEnter into teleport. It will disappear in thirty seconds.", TALKTYPE_MONSTER_SAY, false, 0 ,config.spawnTeleport)
        addEvent(removal, config.timeToRemove * 1000, config.spawnTeleport)
    end
    return true
end
 
Last edited:
Solution
Tested your script, its working for me
You sure u got right position?
Add the local function always above the main function
Local variable aswell if its possible here a example + easier to read ( if u ask me )
LUA:
local config = {
    monsterName = "rotworm",
    spawnTeleport = Position(1000, 1000, 7),
    changePosition = Position(1000, 1013, 7),
    timeToRemove = 5,
}

local function removal(position)
    local teleport = Tile(position):getItemById(1387)
    if teleport then
        teleport:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

function creatureevent.onKill(creature, target)
    if not creature:isPlayer() or not target:isMonster() then
        return true
    end
 
    if target:getName():lower() == config.monsterName then
        local teleport = Game.createItem(1387, 1, config.spawnTeleport)
        if teleport:isTeleport() then
            teleport:setDestination(config.changePosition)
        end
        creature:say("You have defeated Pythius The Rotten!\nEnter into teleport. It will disappear in thirty seconds.", TALKTYPE_MONSTER_SAY, false, 0 ,config.spawnTeleport)
        addEvent(removal, config.timeToRemove * 1000, config.spawnTeleport)
    end
    return true
end

Wrong position... lol... Thanks!
 

Similar threads

Back
Top