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

Creature create tp on death

Yatozin

New Member
Joined
Jun 13, 2014
Messages
49
Reaction score
3
Lua:
-- Boss teleport spawn script by mdwilliams.
-- https://otland.net/threads/tfs-1-2-portal-created-on-monster-death.265567/#post-2567024
-- Converted to TFS 1.3 Revscriptsys by Evil Hero.

local teleportToPosition = Position(1000, 1000, 7)
local teleportCreatePosition = Position(2000, 2000, 7)
local bossName = "boss monster"
local killMessage = "You have killed Boss Monster! A teleport has been created but it will disappear in 5 minutes!"

-- Function that will remove the teleport after a given time
local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
end

local event = CreatureEvent("BossKill")

function event.onKill(creature, target)
    if target:isPlayer() or target:getMaster()  or target:getName():lower() ~= bossName then
        return true
    end

    local position = target:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, teleportCreatePosition)

    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end

    target:say(killMessage, TALKTYPE_MONSTER_SAY, 0, 0, position)

    -- Remove portal after 5 minutes
    addEvent(removeTeleport, 5 * 60 * 1000, position)

    return true
end

event:register()

local login = CreatureEvent("RegisterBossKill")

function login.onLogin(player)
    player:registerEvent("BossKill")
    return true
end

login:register()


For some reason the tp never goes away no errors or anything.
 
Solution
Lua:
-- Boss teleport spawn script by mdwilliams.
-- https://otland.net/threads/tfs-1-2-portal-created-on-monster-death.265567/#post-2567024
-- Converted to TFS 1.3 Revscriptsys by Evil Hero.

local teleportToPosition = Position(1000, 1000, 7)
local teleportCreatePosition = Position(2000, 2000, 7)
local bossName = "boss monster"
local killMessage = "You have killed Boss Monster! A teleport has been created but it will disappear in 5 minutes!"

-- Function that will remove the teleport after a given time
local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
end

local event =...
Lua:
-- Boss teleport spawn script by mdwilliams.
-- https://otland.net/threads/tfs-1-2-portal-created-on-monster-death.265567/#post-2567024
-- Converted to TFS 1.3 Revscriptsys by Evil Hero.

local teleportToPosition = Position(1000, 1000, 7)
local teleportCreatePosition = Position(2000, 2000, 7)
local bossName = "boss monster"
local killMessage = "You have killed Boss Monster! A teleport has been created but it will disappear in 5 minutes!"

-- Function that will remove the teleport after a given time
local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
end

local event = CreatureEvent("BossKill")

function event.onKill(creature, target)
    if target:isPlayer() or target:getMaster()  or target:getName():lower() ~= bossName then
        return true
    end

    local position = target:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, teleportCreatePosition)

    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end

    target:say(killMessage, TALKTYPE_MONSTER_SAY, 0, 0, position)

    -- Remove portal after 5 minutes
    addEvent(removeTeleport, 5 * 60 * 1000, position)

    return true
end

event:register()

local login = CreatureEvent("RegisterBossKill")

function login.onLogin(player)
    player:registerEvent("BossKill")
    return true
end

login:register()


For some reason the tp never goes away no errors or anything.
try change this

addEvent(removeTeleport, 5 * 60 * 1000, position)

to
addEvent(removeTeleport, 5 * 60 * 1000, teleportCreatePosition)
 
Solution
any solution here? Dont seem to work for me, no error in console , the boss gets killed and nothing happens. Running TFS 1.3 newest

Already helped you on Discord but just incase anyone needs help.

Double check you are putting this inside /scripts and you are using a recent TFS version. Then you just need to edit the header with coords/monster name in lower case (this is actually important) and you are good to go. No need to register the script anywhere else.
 
Already helped you on Discord but just incase anyone needs help.

Double check you are putting this inside /scripts and you are using a recent TFS version. Then you just need to edit the header with coords/monster name in lower case (this is actually important) and you are good to go. No need to register the script anywhere else.
You can edit this line, to stop the lowercase issue.
Lua:
if target:isPlayer() or target:getMaster()  or target:getName():lower() ~= bossName then
Lua:
if target:isPlayer() or target:getMaster()  or target:getName():lower() ~= bossName:lower() then
 
Back
Top