• 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.3] (RevScriptSys) - Kill Monster Create Portal

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,530
Solutions
1
Reaction score
83
Location
Portugal
Hey guys, I was searching for this script and the last one I found was created 2 years ago by J.Dre and it wasn't working for me and some other people that I saw on comments, so I fixed the script and added a small countdown feature.

for those who don't know where to add RevScripts this is the path where you can add this script:

data/scripts/killMonsterCreatePortal.lua
Lua:
---------------------------------------------------------------------------------------
-- This script creates a portal when monster dies
---------------------------------------------------------------------------------------


---------------------------------------------------------------------------------------
-- Config start (always write creature name in lower case for ex: "demon" not "Demon")
---------------------------------------------------------------------------------------
local portalId, t = 1387,
{
    ["demon"] = {
        message = "You have defeated Demon!",
        config = {
            createPos = {x = 100, y = 100, z = 7},
            toPos = {x = 100, y = 101, z = 7},
            portalTime = 1, --minutes
        }
    },
    ["orshabaal"] = {
        message = "You have defeated Orshabaal!",
        config = {
            createPos = {}, --NOTE: You may use empty brackets to create the portal where the monster dies.
            toPos = {x = 100, y = 100, z = 7},
            portalTime = 5, --minutes
        }
    },
    ["your mom "] = {
        message = "You have defeated your Mom!",
        config = {
            createPos = {x = 69, y = 69, z = 69}, --NOTE: You may use empty brackets to create the portal where the monster dies.
            toPos = {x = 69, y = 69, z = 69},
            portalTime = 69, --minutes
        }
    },
}
---------------------------------------------------------------------------------------
-- Config end
---------------------------------------------------------------------------------------

local function spectatorStartCountdown(time, position)
    local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5)

    if #spectators > 0 then
        for i = 1, #spectators do
            if time > 1 then
                spectators[i]:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            else
                spectators[i]:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
                break
            end
        end
    end
    addEvent(spectatorStartCountdown, 1000, time - 1, position)
end

local function removePortal(position)
    local portal = Tile(position):getItemById(portalId)
    if portal then
        portal:remove()
    end
end

local killMonsterCreatePortal = CreatureEvent("killMonsterCreatePortal")

function killMonsterCreatePortal.onKill(creature, target)
    if not target:isMonster() or target:getMaster() then
        return true
    end
    
    local player = Player(creature:getGuid())
    local k = t[target:getName():lower()]
    if not k then
        return true
    end
    
    local pos, cPos = target:getPosition()
    if type(k.config.createPos) == 'table' then
        if next(k.config.createPos) == nil then
            cPos = pos
        else
            cPos = k.config.createPos
        end
    end

    if Tile(cPos):getItemById(portalId) then
        return true
    end

    local item = Game.createItem(portalId, 1, cPos)
    if item:isTeleport() then
        item:setDestination(k.config.toPos)
    end
    
    local pt = k.config.portalTime

    player:sendTextMessage(MESSAGE_STATUS_WARNING, k.message .. "\n\nYou have " .. pt .. " " .. (pt > 1 and "minutes" or "minute") .. " to escape through the portal!")
    addEvent(spectatorStartCountdown, 500, pt * 60, cPos)
    addEvent(removePortal, pt * 60 * 1000, cPos)
    return true
end

killMonsterCreatePortal:type("kill")
killMonsterCreatePortal:register()

---------------------------------------------------------------------------------------
-- Register script onLogin
---------------------------------------------------------------------------------------
local monsterKillLogin = CreatureEvent("monsterKillLogin")

function monsterKillLogin.onLogin(player)
    player:registerEvent("killMonsterCreatePortal")
    return true
end

monsterKillLogin:type("login")
monsterKillLogin:register()

ezgif.com-gif-maker.gif
 
Last edited:

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
doesnt works well, when stop countind it still reapetas TIME OUT TIME OUT TIME OUT and so on...
replace function with this one
Lua:
local function spectatorStartCountdown(time, position)
    local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5)

    if #spectators > 0 then
        for i = 1, #spectators do
            if time > 1 then
                spectators[i]:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            else
                spectators[i]:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            end
        end
    end
    if time > 1 then
        addEvent(spectatorStartCountdown, 1000, time - 1, position)
    end
end
 
Last edited:

walltimer

Member
Joined
Aug 5, 2020
Messages
153
Reaction score
18
replace function with this one
Lua:
local function spectatorStartCountdown(time, position)
    local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5)

    if #spectators > 0 then
        for i = 1, #spectators do
            if time > 1 then
                spectators[i]:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            else
                spectators[i]:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            end
        end
    end
    if time > 1 then
        addEvent(spectatorStartCountdown, 1000, time - 1, position)
    end
end
it works now, but script's stil buggy, it count 5.4..3.2..TIMEOUT! :D
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,541
Solutions
384
Reaction score
3,664
it works now, but script's stil buggy, it count 5.4..3.2..TIMEOUT! :D
Lua:
local function spectatorStartCountdown(time, position)
    local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5)

    if #spectators > 0 then
        for i = 1, #spectators do
            if time > 0 then
                spectators[i]:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            else
                spectators[i]:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
            end
        end
    end
    if time > 0 then
        addEvent(spectatorStartCountdown, 1000, time - 1, position)
    end
end
 

Indahouse

Member
Joined
May 13, 2015
Messages
79
Reaction score
10
You can also use this one, i use it for create a very long quests and you can add monsters you want,

Lua:
local fsecondMonsterDungeon = CreatureEvent("fsecondMonsterDungeon") -- Change This
local enemyNames = {
    [1] = "Abyssal Hydra"
}

local function removeTeleport(position)
    local spawnedTeleport = Tile(position):getItemById(17868) -- Teleport ( crystal from warzone tp )
    if spawnedTeleport then
        spawnedTeleport:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
 
    return true
end

local function formatString(s)
    s = string.gsub(s, "[%d%p%c%s]", "")
    s = s:lower()
 
    return s
end

function fsecondMonsterDungeon.onKill(creature, target) -- If you change first line this one also
    if not target or not target:isMonster() then
        return true
    end
 
    local f = false
    local t = formatString(target:getName())
    for _, v in ipairs(enemyNames) do
        if t == formatString(v) then
            f = true
        end
    end
 
    if not f then
        return true
    end

    local teleportSpawn = Position(34709, 32022, 11) -- Position for teleport to spawn 
    removeTeleport(teleportSpawn)
    teleportSpawn:sendMagicEffect(CONST_ME_TELEPORT)
 
    local item = Game.createItem(17868, 1, teleportSpawn)
    if item:isTeleport() then
        local teleportTo = Position(34727, 32023, 11) -- Teleport destination
        item:setDestination(teleportTo)
    end

    target:say('Take the teleport before they disappear!', TALKTYPE_MONSTER_SAY, 0, 0, teleportSpawn) -- Message 
    addEvent(removeTeleport, 200000, teleportSpawn)
 
    return true
end
fsecondMonsterDungeon:register() -- If you change first line this one also
 
Top