• 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.2/1.3 kill monster create portal

yes

creaturescript onKill

if target:getMonster() and target:getName():lower() == 'monster' then
local teleport = Game.createItem(1387, -1, target:getPosition())
Teleport(teleport.uid):setDestination(Position(x, y, z))
end
 
@Xeraphus
how to add a timer ?
you know, time till teleport dissapear

#edit

i don't know why but teleport doesnt appear after killing a monstter
no errors
tfs 1.2

#edit nvm i forgot to add event in login.lua
also i found a teleport with timer
Code:
local cfg = {
    ['rat'] = {tpDestination = Position(433, 504, 7), removeAfter = 30 * 1000}
}

local function remove(pos)
    local item = Tile(pos):getItemById(1387)
    if item then
        item:remove()
    end
end

function onKill(creature, target)
    local tmp = cfg[target:getName():lower()]
    if tmp and target:isMonster() then
        local pos = target:getPosition()
        local teleport = Game.createItem(1387, -1, pos)
        Teleport(teleport.uid):setDestination(tmp.tpDestination)
        addEvent(remove, tmp.removeAfter, pos)
    end
    return true
end
 
Last edited:
Try
creaturescript
Code:
    <event type="kill" name="bosstp" script="bosstp"/>

Lua:
            local bosses = {
               ['demon'] = 50000   ------------> storange can change it for which you do not occupy
            }

            function onKill(player, target)
               local targetMonster = target:getMonster()
               if not targetMonster then
                  return true
               end

               local targetName = targetMonster:getName():lower()
               local bossStorage = bosses[targetName]
               if not bossStorage then
                  return true
               end
                  local function deleteTeleport(position)
                                        local teleport = Tile(position):getItemById(1387)
                                        if teleport then
                                            teleport:remove()
                                          
                                        end
                                    end
              

               local newValue = 2
              
               Game.setStorageValue(bossStorage, newValue)
              
               local item = Game.createItem(1387, 1,{x = 33548, y = 31623, z = 8}) ------> where will be created
            
                                        if item:isTeleport() then
                                            item:setDestination({x = 33495, y = 31583, z = 7}) ------> where will teleport you?
                                        end


               if newValue == 2 then
                  player:say('You now have 1 minute to exit this room through the teleporter.', TALKTYPE_MONSTER_SAY)
                  addEvent(deleteTeleport, 1 * 60 * 1000, {x = 33548, y = 31623, z = 8}) ------> where will remove
               
               end
               return true
            end


login.lua
Code:
player:registerEvent("bosstp")
 
Try
creaturescript
Code:
    <event type="kill" name="bosstp" script="bosstp"/>

Lua:
            local bosses = {
               ['demon'] = 50000   ------------> storange can change it for which you do not occupy
            }

            function onKill(player, target)
               local targetMonster = target:getMonster()
               if not targetMonster then
                  return true
               end

               local targetName = targetMonster:getName():lower()
               local bossStorage = bosses[targetName]
               if not bossStorage then
                  return true
               end
                  local function deleteTeleport(position)
                                        local teleport = Tile(position):getItemById(1387)
                                        if teleport then
                                            teleport:remove()
                                         
                                        end
                                    end
             

               local newValue = 2
             
               Game.setStorageValue(bossStorage, newValue)
             
               local item = Game.createItem(1387, 1,{x = 33548, y = 31623, z = 8}) ------> where will be created
           
                                        if item:isTeleport() then
                                            item:setDestination({x = 33495, y = 31583, z = 7}) ------> where will teleport you?
                                        end


               if newValue == 2 then
                  player:say('You now have 1 minute to exit this room through the teleporter.', TALKTYPE_MONSTER_SAY)
                  addEvent(deleteTeleport, 1 * 60 * 1000, {x = 33548, y = 31623, z = 8}) ------> where will remove
              
               end
               return true
            end


login.lua
Code:
player:registerEvent("bosstp")
he already found a solution
also pls that indentation
lua-users wiki: Lua Style Guide
 
Im running into some issues when trying this script..

Using Nostalrius 1.2 TFS.

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/onkill.lua:onKill
data/creaturescripts/scripts/onkill.lua:17: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/onkill.lua:17: in function <data/creaturescripts/scripts/onkill.lua:12>

Code:
local cfg = {
    ['rat'] = {tpDestination = Position(32010, 32628, 7), removeAfter = 30 * 1000}
}

local function remove(pos)
    local item = Tile(pos):getItemById(1949)
    if item then
        item:remove()
    end
end

function onKill(creature, target)
    local tmp = cfg[target:getName():lower()]
    if tmp and target:isMonster() then
        local pos = target:getPosition()
        local teleport = Game.createItem(1949, -1, pos)
        Teleport(teleport.uid):setDestination(tmp.tpDestination)
        addEvent(remove, tmp.removeAfter, pos)
    end
    return true
end

Could it be that Nostalrius is running its teleports thru movement and every teleports need a UID?
.. Any clues?

Also the teleport doesn't go away after 30 seconds..
 
Back
Top