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

RevScripts cool tp appear idea

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,312
Reaction score
135
hey hey again xd :)) inspiring time xd


i want to ask alot alot please for a revscript, idea like this:

if i kill Demon in area 11/11/7 - 22/22/7 . appear teleport on 11/15/7 for 90 seconds , with leads to 55/55/7.
while teleport is active, shoud be counttimer on tp. Also revscript, so can add multiple lines for different locations/monsters etc.


thanks alot in advance!!!
 
hey hey again xd :)) inspiring time xd


i want to ask alot alot please for a revscript, idea like this:

if i kill Demon in area 11/11/7 - 22/22/7 . appear teleport on 11/15/7 for 90 seconds , with leads to 55/55/7.
while teleport is active, shoud be counttimer on tp. Also revscript, so can add multiple lines for different locations/monsters etc.


thanks alot in advance!!!
Sure...why not xD

Tested using latest TFS (forgottenserver/src/luascript.cpp at 3762d1735a9ed1b65e8a10338470aa3483f86cd9 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/3762d1735a9ed1b65e8a10338470aa3483f86cd9/src/luascript.cpp))

As requested, its a revscript, so just drag and drop into your scripts folder :)
Lua:
local teleportId = 1387
local teleportTime = 90
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
    
    local teleport = event.teleport
    if not teleport then
        return
    end
    
    timer = timer - 1
    
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
    
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
    
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName 
        and player:getPosition():isInRange(event.area.from, event.area.to) 
        and not event.teleport then
            local teleport = Game.createItem(teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, teleportTime)
            end
            break
        end
    end
    
    return true
end
deathTeleportOnKill:register()

local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
 
Last edited:
Sure...why not xD

Tested using latest TFS (forgottenserver/src/luascript.cpp at 3762d1735a9ed1b65e8a10338470aa3483f86cd9 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/3762d1735a9ed1b65e8a10338470aa3483f86cd9/src/luascript.cpp))

As requested, its a revscript, so just drag and drop into your scripts folder :)
Lua:
local teleportId = 1387
local teleportTime = 90
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
   
    local teleport = event.teleport
    if not teleport then
        return
    end
   
    timer = timer - 1
   
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
   
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
   
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, teleportTime)
            end
            break
        end
    end
   
    return true
end
deathTeleportOnKill:register()

local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
Hey hey ! thanks for your given time for it!

what about if i want to have 2 different lines ? example 1 for demon, second for dragon, with all diff info ( text, timeappear, zones, etc)

all the config, shoud be in like 1 line, and script shoud be aible to work with multiple areas/mobs, so i can set more lines. etc
 
Hey hey ! thanks for your given time for it!

what about if i want to have 2 different lines ? example 1 for demon, second for dragon, with all diff info ( text, timeappear, zones, etc)

all the config, shoud be in like 1 line, and script shoud be aible to work with multiple areas/mobs, so i can set more lines. etc
Lua:
local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}
 
Lua:
local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}
yeah but like time for itemTP dissapear also i want to set on every line different, also the text on appear tp i want set for all diff
Post automatically merged:

Lua:
local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}
and right, TpId i want to be mostly all different, so i can set up basicaly any item(ofc walkaibleon) what is tp, so yeah so its possible for every line pick different TpID
 
yeah but like time for itemTP dissapear also i want to set on every line different, also the text on appear tp i want set for all diff
Post automatically merged:


and right, TpId i want to be mostly all different, so i can set up basicaly any item(ofc walkaibleon) what is tp, so yeah so its possible for every line pick different TpID
Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
   
    local teleport = event.teleport
    if not teleport then
        return
    end
   
    timer = timer - 1
   
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
   
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
   
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName:lower()
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
            end
            break
        end
    end
   
    return true
end
deathTeleportOnKill:register()

local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
 
Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
  
    local teleport = event.teleport
    if not teleport then
        return
    end
  
    timer = timer - 1
  
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
  
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
  
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName:lower()
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
            end
            break
        end
    end
  
    return true
end
deathTeleportOnKill:register()

local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
looks nicer, also you forgot the message,


example:


Lua:
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        OnKillSendRedMessage to all who killed monster (all who kills, diff people, single people, party people) = ''you have survived, and a portal have spawned for you''
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}
 
looks nicer, also you forgot the message,


example:


Lua:
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        OnKillSendRedMessage to all who killed monster (all who kills, diff people, single people, party people) = ''you have survived, and a portal have spawned for you''
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
    },
}
Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
   
    local teleport = event.teleport
    if not teleport then
        return
    end
   
    timer = timer - 1
   
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
   
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
   
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
               
                if event.killMessage and event.killMessageType then
                    local damageMap = target:getDamageMap()
                    if damageMap then
                        for playerId, _ in pairs(damageMap) do
                            local contributor = Player(playerId)
                            if contributor then
                                contributor:sendTextMessage(event.killMessageType, event.killMessage)
                            end
                        end
                    end
                end
            end
            break
        end
    end
   
    return true
end
deathTeleportOnKill:register()

--or register "deathTeleportLogin" on player login (data/creaturescripts/login.lua) and remove the code below
local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
 
Last edited:
Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
  
    local teleport = event.teleport
    if not teleport then
        return
    end
  
    timer = timer - 1
  
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
  
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
  
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
              
                if event.killMessage and event.killMessageType then
                    local damageMap = target:getDamageMap()
                    if damageMap then
                        for playerId, _ in pairs(damageMap) do
                            local contributor = Player(playerId)
                            if contributor then
                                contributor:sendTextMessage(event.killMessageType, event.killMessage)
                            end
                        end
                    end
                end
            end
            break
        end
    end
  
    return true
end
deathTeleportOnKill:register()

--or register "deathTeleportLogin" on player login (data/creaturescripts/login.lua) and remove the code below
local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
Will test and tell how it goes :)

big thanks for your given time ! respect :)
Post automatically merged:

Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 7, --default tibia client x radius
    y = 5 --default tibia client y radius
}

local config = {
    {
        bossName = "demon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
  
    local teleport = event.teleport
    if not teleport then
        return
    end
  
    timer = timer - 1
  
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
  
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
  
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
              
                if event.killMessage and event.killMessageType then
                    local damageMap = target:getDamageMap()
                    if damageMap then
                        for playerId, _ in pairs(damageMap) do
                            local contributor = Player(playerId)
                            if contributor then
                                contributor:sendTextMessage(event.killMessageType, event.killMessage)
                            end
                        end
                    end
                end
            end
            break
        end
    end
  
    return true
end
deathTeleportOnKill:register()

--or register "deathTeleportLogin" on player login (data/creaturescripts/login.lua) and remove the code below
local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
Seems no working, and no errros :((
 
Last edited:
Lua:
local teleportCountdownRange = { --how close to the teleport to see the countdown? best to set to your viewport radiuses
    x = 9, --default tibia client x radius
    y = 7 --default tibia client y radius
}

local config = {
    {
        bossName = "gladiator",
        area = {
            from = Position(824, 2790, 7),
            to = Position(825, 2791, 7),
        },
        teleportId = 1387,
        teleportTime = 15,
        teleportPos = Position(827, 2787, 7),
        teleportToPos = Position(829, 2791, 7),
        killMessage = "You have found secret teleport.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
    {
        bossName = "dragon",
        area = {
            from = Position(32320, 32210, 7),
            to = Position(32322, 32213, 7),
        },
        teleportId = 1387,
        teleportTime = 90,
        teleportPos = Position(32320, 32218, 7),
        teleportToPos = Position(32331, 32215, 7),
        killMessage = "You have survived, and a portal has spawned for you.",
        killMessageType = MESSAGE_EVENT_ADVANCE,
    },
}

local function countdownTeleport(eventId, timer)
    local event = config[eventId]
    if not event then
        return
    end
  
    local teleport = event.teleport
    if not teleport then
        return
    end
  
    timer = timer - 1
  
    if timer == 0 then
        teleport:remove()
        event.teleport = nil
        return
    end
  
    local teleportPosition = teleport:getPosition()
    local spectators = Game.getSpectators(teleportPosition, false, true, teleportCountdownRange.x, teleportCountdownRange.x, teleportCountdownRange.y, teleportCountdownRange.y)
    if spectators then
        for _, spectator in ipairs(spectators) do
            spectator:say(timer, TALKTYPE_MONSTER_SAY, false, spectator, teleportPosition)
        end
    end

    addEvent(countdownTeleport, 1000, eventId, timer)
end

local deathTeleportOnKill = CreatureEvent("deathTeleportOnKill")
function deathTeleportOnKill.onKill(player, target)

    if not target:isMonster() then
        return true
    end
  
    local monsterName = target:getName():lower()

    for eventId, event in ipairs(config) do
        if monsterName == event.bossName
        and player:getPosition():isInRange(event.area.from, event.area.to)
        and not event.teleport then
            local teleport = Game.createItem(event.teleportId, 1, event.teleportPos)
            if teleport then
                teleport:setDestination(event.teleportToPos)
                event.teleport = teleport
                addEvent(countdownTeleport, 1000, eventId, event.teleportTime)
              
                if event.killMessage and event.killMessageType then
                    local damageMap = target:getDamageMap()
                    if damageMap then
                        for playerId, _ in pairs(damageMap) do
                            local contributor = Player(playerId)
                            if contributor then
                                contributor:sendTextMessage(event.killMessageType, event.killMessage)
                            end
                        end
                    end
                end
            end
            break
        end
    end
  
    return true
end
deathTeleportOnKill:register()

--or register "deathTeleportLogin" on player login (data/creaturescripts/login.lua) and remove the code below
local deathTeleportLogin = CreatureEvent("deathTeleportLogin")
function deathTeleportLogin.onLogin(player)
    player:registerEvent("deathTeleportOnKill")
    return true
end
deathTeleportLogin:register()
Post automatically merged:

show me your config
here , i go to gladiator and it wont react if i kill gladiators on that area
 
Post automatically merged:


here , i go to gladiator and it wont react if i kill gladiators on that area

Watch the video I linked above. Not sure why its not working for you, double check your positions, and also double check all the methods/functions used in the script. It may be that you are missing some.

Also, double check you have no startup errors....
 

Watch the video I linked above. Not sure why its not working for you, double check your positions, and also double check all the methods/functions used in the script. It may be that you are missing some.

Also, double check you have no startup errors....
yeah you told it works for you, i use 10.98 1.4 tfs+ , maybe it can make some sense ? im not programer at all :(
 
Are you 100% sure there are no errors when you start the server?
it would hit an error while i try kill creature in this area ? im not sure about all errors i get on statrup, but on reload scripts i aint getting error about this
 
it would hit an error while i try kill creature in this area ? im not sure about all errors i get on statrup, but on reload scripts i aint getting error about this
reloading revscripts doesnt even work correctly in TFS.
locally when you're testing, it's always best to restart the server, never reload! Reloading can produce false and weird behaviour.

But the script is fine, you just need to figure out what is wrong or not, check your src/luascript.cpp and check the methods to see if they are all good.
 
reloading revscripts doesnt even work correctly in TFS.
locally when you're testing, it's always best to restart the server, never reload! Reloading can produce false and weird behaviour.

But the script is fine, you just need to figure out what is wrong or not, check your src/luascript.cpp and check the methods to see if they are all good.
if script is xxx/yy/zz i always also restart to test also the server. did it many times, :)


im not programer i dont know what shoud i whatch and what means what :(
 
@Fjorda
I had to join his server to test a boss kill event. Indeed, his TFS source is quite buggy. I recommend switching to a newer TFS. I sent him about 6 different scripts, and none of them worked for him, lol. I tested my TFS, and it worked fine, but it gave an error in his console. I think his source is very buggy or poorly optimized or something like that. I don't know.
 
Back
Top