• Sign up for TFS Icon Competition! The prize includes Otland Premium time and a medal, as well as obviously taking part in TFS history.
  • 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,529
Solutions
1
Reaction score
80
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:
Top